There are --init
and --init-path
options for docker run
, but it's not clear how to use it.
At first, I thought it's something like dumb-init, but included in docker core (kind of "native"). But --init
key demands --init-path
to be set as well, pointing to 'docker-init binary', and gives no clue on where to take it. Google is silent about 'docker-init'.
Okay, maybe I'm supposed to use 'yelp/dumb-init' or 'phusion/baseimage-docker', but those solutions don't seem to use docker run
's --init
option.
So, I'm curious where do I take this "docker-init binary" to set the --init-path
to?
I've found this in documentation:
I couldn't find
docker-init
on a macOS Docker installation, but on Linux it's here:/usr/bin/docker-init
Specifiying the new docker --init option in the run command basically sets ENTRYPOINT to tini and passes the CMD to it or whatever you specify on the commandline.
For example, without init, CMD becomes pid 1. In this case, /bin/bash
With --init, tini (/dev/init) becomes pid 1
tini is a first class init process that can be run as pid 1 correctly. A pid 1 process must reap forked child processes correctly, if it doesn't then bad things happen like resources get leaked and zombies appear.
This is what you want for applications that fork and haven't been written with child reaping in mind as normally they would leave this up to the init system. A classic example is java Jenkins applications.