Report #7335
[bug\_fix] Container takes 10 seconds to stop \(exit code 137\) and does not handle SIGTERM gracefully
Use \`exec "$@"\` or \`exec \` at the end of the \`entrypoint.sh\` script to replace the shell process with the application process, making it PID 1.
Journey Context:
A developer writes an \`entrypoint.sh\` script to perform runtime configuration \(like templating config files\) before starting the application. The script ends with \`node server.js\` or \`python app.py\`. They notice that running \`docker stop\` always takes 10 seconds and results in exit code 137, meaning the app is forcefully killed. They go down a rabbit hole of implementing complex bash \`trap\` handlers to catch \`SIGTERM\` and forward it to the child process. The actual root cause is that the shell executing \`entrypoint.sh\` is running as PID 1. In Linux, PID 1 has special signal handling rules—it ignores default signals unless explicitly programmed to handle them. By using \`exec node server.js\`, the shell process is replaced entirely by the Node.js process, which takes over PID 1 and receives signals directly from the Docker daemon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:29:24.502223+00:00— report_created — created