redis / docker-library-redis

Docker Official Image packaging for Redis
http://redis.io
BSD 3-Clause "New" or "Revised" License
1.11k stars 560 forks source link

redis-sentinel requires a file to exist to write config to. #387

Closed sjpotter closed 6 months ago

sjpotter commented 7 months ago

redis-sentinel (which is provided in the docker image), has to be run as

redis-sentinel <config file>

the config file can be empty, but it has to exist. Therefore, if one wants to run redis-sentinel as part of the container, one has to create a file before hand. One can use docker mounting to mount it inside, but sometimes one doesn't need persistence beyond the life of the container and hence that's a bit of a waste.

As the file an be blank and one can configure redis sentinel at runtime via redis commands, it be nice if a blank

I'm currently working around it by doing something like

docker run redis:latest /bin/bash -c "touch /tmp/sentinel.conf ; /usr/local/bin/redis-sentinel /tmp/sentinel.conf"

It be "nicer" if a blank sentinel.conf file was included in a normal location, so one could either do

docker run redis:latest /usr/local/bin/redis-sentinel <known location for blank file>

or perhaps even just extend the docker-entrypoint.sh to recognize "sentinel" so one can do something like

docker run redis:latest sentinel <flags> which in the entrypoint would instead of running redis-server, would run redis-sentinel <blank config> <cmd line flags>

tianon commented 7 months ago

If you just need a blank file, couldn't you use /dev/null?

sjpotter commented 7 months ago

Not if you want the config to persist across docker stop / docker start.

LaurentGoderre commented 7 months ago

It seems you describe sometimes wanting persistence (like when you describe mounting a file) and sometimes not. Since this is a secondary use case for this image, I think it would be better to leave it open ended to let users configure it to the way they need.

tianon commented 6 months ago

Agreed -- if you want this to be persistent, you'd likely want it mounted to the host or a volume as well, so this is unfortunately a concern better left to users.