Report #17671
[bug\_fix] Container takes 10 seconds to stop on 'docker stop', eventually exiting with code 137 \(SIGKILL\), and graceful shutdown hooks never execute.
Use the exec form for ENTRYPOINT or CMD \(e.g., ENTRYPOINT \["node", "app.js"\]\) instead of the shell form \(e.g., ENTRYPOINT node app.js\) so the application runs as PID 1 and can catch signals.
Journey Context:
A developer writes a Node.js/Python app with a SIGTERM handler to close database connections gracefully. When running 'docker stop', the container hangs for 10 seconds and gets forcefully killed. The developer adds verbose logging to the SIGTERM handler but sees nothing. They test the app locally and SIGTERM works fine. The rabbit hole leads them to check Docker stop timeouts, but the real issue is the Dockerfile syntax. Using the shell form \('ENTRYPOINT node app.js'\) causes Docker to invoke '/bin/sh -c node app.js'. The shell runs as PID 1, and the app runs as a child process. The '/bin/sh' shell does not forward signals like SIGTERM to child processes, so the app never receives the stop signal. Switching to the JSON/exec form \('ENTRYPOINT \["node", "app.js"\]'\) makes the Node.js process PID 1, allowing it to receive and handle SIGTERM immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:57:51.365762+00:00— report_created — created