I'm trying to pass my redis password using docker-compose
via environment variable but it gives me errors.
Here is part of mine docker-compose.yml
with redis image:
redis:
image: redis
container_name: redis
# command: redis-server --requirepass mypassword <--- this works as expected
# command: redis-server --requirepass ${REDIS_PASSWORD} <-- while this does not
command: redis-server --requirepass $${REDIS_PASSWORD} <-- and this does not work either
volumes:
- redis:/var/lib/redis/data
- ./redis.conf:/usr/local/etc/redis/redis.conf
ports:
- "6379"
env_file:
- .env.prod
My .env.prod
:
REDIS_PASSWORD=mypassword
It gives me an error:
consumer: Cannot connect to redis://:**@redis:6379/0: WRONGPASS invalid username-password pair or user is disabled..
But if I specify password directly in docker-compose.yml
without env variable, then it works.
/bin/sh
&-c
as well :) – Coralloid