SnitchDNS icon indicating copy to clipboard operation
SnitchDNS copied to clipboard

Docker container does not respond to SIGTERM signal

Open jnehlmeier opened this issue 3 years ago • 2 comments

When calling docker stop snitch the container does not shutdown the services and exits. So it does not respond to SIGTERM signals. Docker will wait some time, by default 10 seconds, and then send SIGKILL to kill the process. Always waiting 10 seconds is kind of annoying. As a consequence your app won't shutdown gracefully at all in case that is important.

The issue is that you are calling bash entrypoint.sh to start 3 processes and bash ignores signals and does not forward them to processes. As a workaround I have to use docker run --init to let docker insert a small init process as PID 1 which then manages your bash entrypoint.sh process. That way I don't have to wait 10 seconds, but signals still won't be forwarded to your processes for graceful shutdown.

So at least add --init to your tutorial and/or make your PID 1 process more compliant.

jnehlmeier avatar Mar 05 '22 20:03 jnehlmeier

Got to admit that Docker isn't my strongest suit, I'll do some reading and fix it - thanks for the tips!

sadreck avatar Mar 09 '22 07:03 sadreck

A common work around for providing signal handling without implementing it, is to wrap tini around the entrypoint, and it will take care of the rest.

It's a low effort solution.

almereyda avatar Nov 11 '23 21:11 almereyda