PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 18, 2022

[FIXED] Why Redis in Docker need set daemonize to no?

 October 18, 2022     docker, redis     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing