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 stop - SIGTERM/SIGINT aware processes exit only with SIGKILL #1063
Comments
@unclejack I merged your PR today, is this still relevant? |
@crosbymichael Yes, this is still a problem. I'll close it since it requires further investigation and it's not immediately actionable. |
Any news about this issue ? I've got postgresql that doesn't close cleanly with I'd certainly prefer to shutdown the DB the right way, instead of cutting it off altogether. |
The right solution might be #2100 (shutdown hooks), what do you think? |
Same problem with mysql (mariadb-galera cluster) - unclean (forced) shutdown with docker stop causes cluster to split brain (when stopping 2 nodes out of 3 cluster nodes). Shutdown hook could be a solution - at least better than nothing atm. |
Well - with 1.3 exec feature there is a possibility for a workaround for time being - just executing before docker stop cmd: docker exec -it <ct-name> <process-graceful-stop-script-or-cmd> Worked for me - but shutdown hook would be more proper way imho. |
@abourget: postgres may not shut down in a timely manner in response to |
This issue is rather strange. Processes which handle SIGTERM and SIGINT properly exit with exit code 137. This is the exit code shown in docker ps and this is the exit code printed by docker wait. Exit code 137 is usually the exit code one gets after sending SIGKILL to a process.
In the case of jpetazzo/pgsql, it exits cleanly within the container, but the exit code of the container is 137
Not being able to stop some processes launched in the containers via SIGTERM/SIGINT (even though they do handle those signals properly when running on the host) and not being able to get the actual exit code makes it very difficult to monitor processes running under docker containers with a process monitoring solution.
Processes which usually exit with exit code 0 after a SIGTERM/SIGINT exit with exit code 137. This is detected as an error.
Based on the above, we either have 2 issues or one issue causing two problems:
1 SIGTERM isn't always passed on properly to the process running in the container
Docker stop has to reach the timeout and kill the container with SIGKILL.
This happens even with processes which handle SIGTERM / SIGINT properly on the host.
2 The real exit code of the process running in the container isn't shown in docker ps
This seems to happen when launching something from a shell script within another shell and in many other situations.
The only case in which I was able to get the real exit code of the container & make it handle SIGTERM is when launching pgsql by hand (directly running su postgres sh -c "....", without using the shell script) from the pgsql docker image.
update:
Here are some examples:
/cc @shykes @jpetazzo @creack
The text was updated successfully, but these errors were encountered: