Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Redis in Docker need set daemonize to no?

Tags:

docker

redis

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
like image 985
petrie Avatar asked Oct 18 '25 15:10

petrie


1 Answers

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

like image 200
OneCricketeer Avatar answered Oct 20 '25 10:10

OneCricketeer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!