ctxis / SnitchDNS

Database Driven DNS Server with a Web UI

Home Page:https://www.contextis.com/en/resources/tools/snitchdns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docker container does not respond to SIGTERM signal

jnehlmeier opened this issue · 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.

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

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.