Yelp/dumb-init

Cannot operate services when a container is detached

Chi-teck opened this issue · 6 comments

I am maintaining a Docker image that utilizes dumb-init to spawn processes.
Recently I found that I cannot manage services in docker container anymore.

This works well when a container is running in foreground.

docker run --rm -uroot -it attr/drupal-lemp service nginx stop
[ ok ] Stopping nginx: nginx.

However whey I use drush run -d + drush exec it fails.

docker run --name=c1 -d attr/drupal-lemp && docker exec -uroot c1 service nginx stop
d4d38832ec1b896faa65631ba324b4bfb5335ddd0e4bfced3a8caab750c94142
Stopping nginx: nginx failed!

This might happen because the dumb-init is started by unprivileged user with sudo.
I had to add sudo there because Docker does not allow to set USER after CMD.

Correct me if I'm wrong but use of service usually implies you're using some more advanced init system (such as upstart / systemd) and not using dumb-init. dumb-init is designed to be an init system which manages a single process or tree and is not a general purpose service watcher.

The intended setup (for nginx for example) is to run nginx in the foreground as a direct child of dumb-init.

dump-init works very well for me with services when running without sudo.

The intended setup (for nginx for example) is to run nginx in the foreground as a direct child of dumb-init.

If so what would be the correct way to start multiple services in a single container configuration? Here is what I am using right now.
https://github.com/Chi-teck/drupal-lemp/blob/414bec6f3016d83fd093ce61747c405d67608761/cmd.sh

You'll want to use some sort of service manager such as runit / supervisord

I have explained how to configure runit in another issue. #158 (comment)

Thanks, I'will take a look at runit.