Report #47995
[bug\_fix] Container takes 10\+ seconds to stop on \`docker stop\`, eventually exiting with code 137 \(SIGKILL\).
Use the exec form of \`ENTRYPOINT\` or \`CMD\` \(e.g., \`CMD \["python", "app.py"\]\`\) instead of the shell form \(\`CMD python app.py\`\), or explicitly use \`exec\` in an entrypoint script \(\`exec "$@"\`\).
Journey Context:
A developer runs a Node.js or Python app in a container. When they run \`docker stop\`, the container hangs for 10 seconds and then gets force-killed \(exit code 137\). They try to handle SIGTERM in their application code, but the handler is never triggered. They go down a rabbit hole of Node.js/Python signal handling quirks and Alpine musl libc differences. The root cause is that they used the shell form of CMD/ENTRYPOINT \(\`CMD python app.py\`\). The shell form runs the command as a child of \`/bin/sh -c\`, which becomes PID 1 inside the container. PID 1 in Linux is responsible for reaping zombies and forwarding signals. \`/bin/sh\` does not forward SIGTERM to its child processes, so the application never receives the stop signal. After the 10-second timeout, Docker resorts to a SIGKILL. The fix is to use the exec form \`CMD \["python", "app.py"\]\`, which makes \`python\` PID 1 and allows it to receive signals directly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T11:02:49.557118+00:00— report_created — created