Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker container does not respond to SIGTERM signal #15

Open
jnehlmeier opened this issue Mar 5, 2022 · 2 comments
Open

Docker container does not respond to SIGTERM signal #15

jnehlmeier opened this issue Mar 5, 2022 · 2 comments
Assignees

Comments

@jnehlmeier
Copy link

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.

@sadreck sadreck self-assigned this Mar 9, 2022
@sadreck
Copy link
Contributor

sadreck commented Mar 9, 2022

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

@almereyda
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants