Report #23949
[bug\_fix] Container takes 10 seconds to stop and exits with code 137 \(SIGKILL\)
Use the exec form of ENTRYPOINT/CMD \(JSON array\) or add \`exec "$@"\` to the entrypoint shell script so the application runs as PID 1 and receives OS signals directly.
Journey Context:
A developer runs a Node.js application in a container using a shell script entrypoint to set up environment variables before starting the app: \`ENTRYPOINT \["/bin/sh", "entrypoint.sh"\]\` with \`CMD \["node", "server.js"\]\` inside the script. When they run \`docker stop\`, the container ignores the SIGTERM signal, hangs for exactly 10 seconds, and then gets forcefully killed with SIGKILL \(exit code 137\). They dive into process tree debugging, running \`docker exec\` to check PIDs, and discover their Node app is running as PID 7, while \`/bin/sh\` is PID 1. Since Linux only sends SIGTERM to PID 1, and \`/bin/sh\` does not forward signals to child processes, the app never receives the graceful shutdown signal. They fix it by adding \`exec "$@"\` at the end of \`entrypoint.sh\`, which replaces the shell process with the Node.js process, making Node PID 1 and allowing it to catch SIGTERM.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:36:26.466405+00:00— report_created — created