Report #17490
[bug\_fix] Container takes 10 seconds to stop on docker stop \(exits with code 137\)
Use the exec form of CMD or ENTRYPOINT \(e.g., \`CMD \["python", "app.py"\]\`\) instead of the shell form \(\`CMD python app.py\`\) so the application runs as PID 1 and receives SIGTERM directly.
Journey Context:
A developer notices that \`docker stop\` takes exactly 10 seconds to complete, and containers exit with code 137 \(SIGKILL\) instead of a graceful 0 or 143. They realize the application is not receiving the SIGTERM signal to shut down gracefully. Inspecting the Dockerfile, they see \`CMD python app.py\`. This shell form causes Docker to run the command as a child of \`/bin/sh -c\`, making \`/bin/sh\` PID 1. The Linux kernel only sends signals like SIGTERM to PID 1, and \`/bin/sh\` historically does not forward these signals to child processes. By changing to the exec form \`CMD \["python", "app.py"\]\`, Python becomes PID 1 and handles the SIGTERM signal immediately, allowing graceful shutdowns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:27:39.160898+00:00— report_created — created