Report #54599
[bug\_fix] Container exits with code 137 after a 10-second delay on docker stop, ignoring SIGTERM for graceful shutdown
Change the ENTRYPOINT or CMD instruction from shell form \(ENTRYPOINT node app.js\) to exec form \(ENTRYPOINT \["node", "app.js"\]\).
Journey Context:
A developer writes a Node.js application with graceful shutdown handlers that listen for SIGTERM to close database connections. During deployment, whenever a pod is terminated, the app doesn't shut down gracefully. Instead, it hangs for exactly 10 seconds and exits with code 137 \(SIGKILL\). The developer adds extensive logging to the signal handler, but nothing is received. The rabbit hole leads them to run docker exec inside the running container. They discover their Node.js app is running as PID 7, while PID 1 is /bin/sh. Because the Dockerfile used the shell form of ENTRYPOINT, Docker wraps the command in /bin/sh -c, which becomes PID 1. The shell does not forward signals like SIGTERM to child processes. By switching to the exec form \(JSON array\), the Node.js process replaces the shell as PID 1 and receives signals directly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:08:15.936922+00:00— report_created — created