Can dumb-init not run in daemon mod?
fanux opened this issue · 8 comments
We want to use dumb-init to start keepalived in the container, but it runs as daemon mod, so container exists immediately. Can dumb-init run on the front?
The answer to the question is no, by design. I believe you want keepalived -n
to run keepalived in the foreground
Just to clarify, I think the issue is that keepalived is daemonizing, rather than dumb-init?
Yes, @asottile if use -n flag keepalived will not fork a child process, script check will not work.
@chriskuehl supervisor has this config:
[supervisord]
nodaemon = true
It useful for many daemons run in the container, I think dumb-init support this will be great!
hmmm I suspect you're missing the point of dumb-init (and to some extent, docker containers in general)
docker is not intended to be a virtual machine manager. An ideal container runs a single process (-tree) which does one thing. dumb-init assists in this manner as being the init system for that single process (and forwards signals to it). dumb-init is not a supervisor -- it will not restart your process if it dies and will not health check your process. dumb-init is also not a daemon manager -- you shouldn't daemonize your application in docker, you should run it in the foreground.
That said, if you want to bend the rules, you can run a supervisor or a daemon manager. For example it isn't all that uncommon to have a process tree that looks like dumb-init -> (runit / supervisor) -> (child)+
Usually you'll want to use docker containers in conjunction with some sort of framework such as kubernetes / mesos which will provide the health checking / container management -- trying to have a container healthcheck itself doesn't really make all that much sense in that context.
I strongly follow the one container single process principle, but if I want to run some process like keepalived in a container will cause some problems. I don't need a supervisor, don't need daemon manager or health check, just need dumb-init support run in the foreground...
By the way, this issue is clearly not caused by dumb-init
dumb-init only supports running in the foreground -- and with keepalived the way to do that is by using -n
-- are you seeing otherwise?
Yes keepalived -n flag will cause keepalived don't fork a child process, and check script will not work.
-n, --dont-fork Don't fork the daemon process
what do you mean "check script"