I'm trying to pass my redis password to docker-compose via environment variable but it gives me an errors.
Here is mine part of mine docker-compose with redis image:
redis:
image: redis
container_name: redis
# command: redis-server --requirepass mypassword <--- this works as expected
# command: redis-server --requirepass ${REDIS_PASSWORD} <-- this is not
command: redis-server --requirepass $${REDIS_PASSWORD} <-- and this is not
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 specifying password directly in docker-compose without env variable it works.