I would like to set a password on my Redis server running on docker. I have followed the instcruction on https://registry.hub.docker.com/_/redis/:
1.I have created a folder with a Dockerfile containing:
FROM redis
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
2.I have added a redis.conf file with:
requirepass thepassword
3.I built the image using:
docker build -t ouruser/redis .
4.I started the container:
docker run --name my-redis -p 0.0.0.0:6379:6379 -d ouruser/redis redis-server --appendonly yes
The redis server does not have any password ! I do not understand why.
The run command:
docker run --name my-redis -p 0.0.0.0:6379:6379 -d ouruser/redis redis-server --appendonly yes
Overrides the CMD defined in the Dockerfile with redis-server --appendonly yes
, so your conf file will be being ignored. Just add the path to the conf file into your run command:
docker run --name my-redis -p 0.0.0.0:6379:6379 -d ouruser/redis redis-server /usr/local/etc/redis/redis.conf --appendonly yes
Alternatively, set up an entrypoint script or add --appendonly yes
to the CMD instruction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With