What it means
docker stop sends SIGTERM to PID 1, waits (10 s by default), then sends SIGKILL (exit 137). If PID 1 is a shell running your app, the shell doesn't forward the signal, and PID 1 also ignores signals it has no handler for.
Causes and fixes
Most likely first. Run the check, and if it matches, apply the fix.
1. Shell-form CMD or an entrypoint script that doesn't exec the app
Check:
docker exec <c> ps -o pid,args # PID 1 is sh -c ...
Fix: Use exec-form CMD ["app"] and end entrypoint scripts with exec "$@".
2. The app has no SIGTERM handler
Check:
time docker stop <c>
Fix: Handle SIGTERM (finish requests, close connections), or run with --init (tini) as PID 1.
Fix it yourself
A live machine in your browser with this problem already on it. The grader checks the result.
- Make the App Receive SIGTERMmedium 10 min
- Graceful Shutdown in Composemedium 9 min
- Stop Cleanly on SIGTERMhard 14 min
No account needed for your first tries.
Related errors
- Process won't stop (kill doesn't work)
The process ignores SIGTERM, is stuck in the kernel (D state), or is a zombie that's already dead.
- OOMKilled (exit code 137)
The container used more memory than its limit and the kernel killed it.