Closed codespearhead closed 5 months ago
@asottile I updated the previous message for clarity's sake.
Your minimal example is not really minimal?
Here you go (no need for NodeJS, that JS is effectively just doing sleep
, but with a visual countdown):
# CTRL+C will not stop the process exiting the container:
docker run --rm alpine sleep 30
# CTRL+C will now stop the container immediately (`--init` uses built-in `tini`):
docker run --rm -init alpine sleep 30
sleep
is PID 1, and PID 1 does not setup default signal handlers, so if your process does not take care of that it'll ignore the signal SIGINT
sent via CTRL+C. If you want to immediately exit CTRL+\ will send SIGQUIT
which is more akin to SIGKILL
, but will often output a core dump with it.exec command-here
, which will make the new command PID 1).
dumb-init
defaults to forwarding to an entire process group (if the README example with sleep
is not helpful, you can see another comparison demonstrated here).This is just a signal handling example, not handling zombie processes.
Add a MRE of the problem mentioned in the very first bullet-point of section "Why you need an init system", which can be solved by using dumb-init in the Dockerfile