Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to supervisord for docker

Supervisord is really great tool even for docker environment. It helps a lot with stderr redirection and signals forwarding. But it has a couple of disadvantages:

  1. It doesn't support delayed startup. It could be useful to delay some agent startup until main app is initializing. Priority doesn't solve this issue.
  2. If some app enters FATAL state supervisord just logs it but continue to work. So you can't see it until look at logs of container. It could much more friendly if supervisord just stops because in that case you see the problem with docker ps -a

So what is the best alternative to supervisord?

like image 750
4ybaka Avatar asked Nov 22 '15 00:11

4ybaka


People also ask

Should I use Supervisord in Docker?

Also, supervisor is used when we need to run multiple process within the container. I have seen several examples where a container is started from base image and several service are installed and the container is committed to form a new image, all without supervisor.

What is Supervisord in Docker?

A supervisor is a tool that allows us to manage a number of different processes simultaneously in Linux like operating system. The supervisor tool requires a . conf file where we specify the processes and different options related to that process like the output log location, auto start, auto restart, etc.

How do I run multiple processes in a container?

Use a process manager which can run multiple processes: You can set the container's entrypoint to a specialised program which is capable of running and managing multiple processes. One example of this is supervisord. You can use supervisord as your container entrypoint, which will then load the services that you need.

How can you run multiple containers using a single service?

A container's main running process is the ENTRYPOINT and/or CMD at the end of the Dockerfile . It is generally recommended that you separate areas of concern by using one service per container. That service may fork into multiple processes (for example, Apache web server starts multiple worker processes).


1 Answers

In response to the "PID1 zombie reaping" issue, I recommended before (in "Use of Supervisor in docker") to use runit instead of supervisord

Runit uses less memory than Supervisord because Runit is written in C and Supervisord in Python.
And in some use cases, process restarts in the container are preferable over whole-container restarts.

See the phusion/baseimage-docker image for more.


As noted by Torsten Bronger in the comments:

Runit is not there to solve the reaping problem.
Rather, it's to support multiple processes. Multiple processes are encouraged for security (through process and user isolation).

Since 2015, you now can Specify an init process that should be used as the PID 1 in the container, with docker run --init

The default init process used is the first docker-init executable found in the system path of the Docker daemon process.
This docker-init binary, included in the default installation, is backed by tini.

like image 56
VonC Avatar answered Sep 18 '22 17:09

VonC