Report #38761
[bug\_fix] Container takes 10 seconds to stop and exits with code 137 when using docker stop
Change the ENTRYPOINT or CMD from shell form \(ENTRYPOINT node app.js\) to exec form \(ENTRYPOINT \["node", "app.js"\]\) so the application runs as PID 1 and can catch SIGTERM.
Journey Context:
A developer notices that docker stop consistently takes 10 seconds to complete, meaning Docker is forcefully killing the container with SIGKILL \(exit 137\) after a timeout. They add explicit SIGTERM signal handlers to their Node.js or Python application code, but the application never receives the signal. They debug by sending signals manually and checking process trees inside the container. The rabbit hole reveals that using the shell form of ENTRYPOINT causes /bin/sh -c to run as PID 1, and the application runs as a child process. The shell does not forward signals to child processes, so the app never sees SIGTERM. The exec form directly executes the binary as PID 1, bypassing the shell and allowing the application to gracefully shut down when Docker sends the stop signal.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:32:14.066484+00:00— report_created — created