Golo Roden
Golo Roden

Reputation: 150862

How critical is dumb-init for Docker?

I hope that this question will not be marked as primarily opinion-based, but that there is an objective answer to it.

I have read Introducing dumb-init, an init system for Docker containers, which extensively describes why and how to use dumb-init. To be honest, for someone not too experienced with how the Linux process structure works, this sounds pretty dramatic - and it feels as if you are doing things entirely wrong if you don't use dumb-init.

This is why I'm thinking about using it within my very own Docker images… what keeps me from doing this is the fact that I have not yet found an official Docker image that uses it.

If dumb-init is so important - why is apparently nobody using it? What am I missing here?

Upvotes: 82

Views: 43317

Answers (3)

doubleopinter
doubleopinter

Reputation: 1

I was just going through this myself. In my case, we have dockerized a JAVA application. The application implements signal handling, so everything works just fine. However, there is one section, used for generating some HTML reports via a chrome back end, which was added by some other devs. I'm not sure if this an issue with that implementation or a characteristic of that chrome back end but I've recently found that some long running containers have thousands of zombie chrome processes. I just added dumb-init to that image and it cleans those zombies up very effectively.

I guess my takeaway is that I don't think there's any down side to using a simple init system in an image, so why not. It certainly helps protect against bad code. I think it's also different if an application is developed with direct knowledge that it will run in a container. In that case the devs can make the right decisions from the start. Otherwise you just don't know.

Upvotes: 0

Jan Pokorný
Jan Pokorný

Reputation: 1868

Nowadays, docker run has the --init option, which runs the container using tini (similar to dumb-init). Thus, you have the option to use it with any image -- if only for the practical reason of being able to use Ctrl-C to stop the process.

Upvotes: 16

Stefan Scherer
Stefan Scherer

Reputation: 1164

Something like dumb-init or tini can be used if you have a process that spawns new processes and you don't have good signal handlers implemented to catch child signals and stop your child if your process should be stopped etc.

If your process doesn't spawn new processes (e.g. Node.js), then this may not be necessary.

I guess that MongoDB, PostgreSQL, ... which may run child processes have good signal handlers implemented. Otherwise there would have been zombie processes and someone would have filed an issue to fix this.

Only problem may be the official language images, like node, ruby, golang. They don't have dumb-init/tini in it as you normally don't need them. But it's up to the developer which may implement bad child execution code to either fix the signal handlers or use helper as PID 1.

Upvotes: 50

Related Questions