Issue
I run my Docker container as below cmd, but the container can't work. When I change the config daemonize yes
to daemonize no
in redis-6379.conf
, it works! Who can tell me why?
➜ ls
6379.log docker-entrypoint.sh dump.rdb redis-6379.conf
➜ cat redis-6379.conf
port 6379
daemonize yes
logfile "6379.log"
dbfilename "dump-6379.rdb"
dir "/data/"
➜ docker run -p 6379:6379 -v /root/redis-sentinel:/data --name redis-6379 -d redis ./redis-6379.conf
➜ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Solution
When you demonize the Redis process, the final Docker exec process (the one that started Redis) has nothing left to do, so that process exits, and the container ends itself.
If you want to keep the container up, you can either not demonize it, or you can, but you must do something else like call wait
, or more preferably, tail -f
the redis logs. However, then the Redis process won't be PID 1, so Redis won't shutdown properly when the container stops
Answered By - OneCricketeer Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.