19

Supervisord is a really great tool, even for a Docker environment. It helps a lot with standard error 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 the main application is initializing. Priority doesn't solve this issue.
  2. If some application enters a fatal state, supervisord just logs it, but it continues to work. So you can't see it until looking at logs of the container. It could be 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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
4ybaka
  • 2,954
  • 4
  • 16
  • 21

3 Answers3

12

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.

chrismacp
  • 3,834
  • 1
  • 30
  • 37
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Actually, the link does explain why also runit does not solve the “PID1 zombie reaping” issue. – Torsten Bronger May 21 '18 at 13:32
  • 1
    @TorstenBronger Agreed. Nowadays, we have `docker run --init`, and tini. I have edited the answer to update it. – VonC May 21 '18 at 14:32
5

Any new visitor:

If you are a beginner to containerization it is highly recommended to use one process per container it makes everyone's life easy.

Without any hack, all other tools will work perfectly, it will improve Observability as well.

Don't treat containers like VMs.

WSMathias9
  • 669
  • 8
  • 15
  • 14
    This isn't answering the question. – Eric Jun 25 '21 at 11:48
  • Containers can be treated as VMs , Check LXD. Docker isn't designed to be treated as VM. Containers != Docker . – Phyo Arkar Lwin Sep 30 '21 at 13:25
  • some time you need to have two or more process started in one container... the 1sr exemple i think is php-fpm they need web server in front using fastcgi serving the same directory... idealy using unix socket.... – Mathieu CARBONNEAUX Jun 07 '22 at 17:44
  • We can easily share Unix sockets between containers and mount the common path/dir and still continue one process per container I am not forcing anyone to do this I am just recommending it from my personal experience it takes observability to the next level. @Eric I am offering an alternative approach to Supervisord as per the title which brought me here. – WSMathias9 Jun 10 '22 at 04:02
1

I am not sure why you'd need supervisor if you have Docker.

Docker does everything supervisor does, start/stop/manage services, and keep the standard output/standard error stored so you can read it later. Restart everything after reboot.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mathieu Longtin
  • 15,922
  • 6
  • 30
  • 40