Running containers with --init
is safe, and if you're at all worried about this class of problem, go ahead and do it. (If you ever run containers in a context that's not pure Docker, note that Kubernetes does not have an equivalent option and you need to have an init process built into your image.)
In both of these cases, code inspection can help you figure out if there's even potentially a problem. Do you ever launch a subprocess? A typical Docker-packaged HTTP service doesn't. If you don't, then a child process can never launch a grandchild process and then exit without cleaning it up, so you can never inherit an unexpected zombie child process. Similarly, if you never launch a subprocess, then the only things that can send you signals are your own code and docker stop
, and you can easily tell if there's a problem there.
None of the standard Docker Hub images I've looked at in detail run an init system. Stack Overflow Docker questions seem to contain very few complaints about docker stop
not working, or about processes leaking on the host. I wouldn't especially worry about this, unless you have evidence to think you have a problem, or if you're trying to check absolutely every last "it's a good idea to..." box.