Report #39355
[bug\_fix] Container takes 10 seconds to stop and exits with code 137 \(SIGKILL\)
Add \`exec "$@"\` or \`exec "$0" "$@"\` at the end of the entrypoint shell script to replace the shell process with the application process, making the application PID 1.
Journey Context:
A developer writes an entrypoint.sh script to perform dynamic environment variable substitution before starting the application. They notice that \`docker stop\` always takes exactly 10 seconds and the container exits with 137. They dig into Docker signal handling and learn that the shell running entrypoint.sh becomes PID 1 inside the container. By default, the Linux kernel does not forward signals \(like SIGTERM from \`docker stop\`\) to child processes of PID 1 unless it explicitly sets up a handler. The shell ignores the SIGTERM, causing Docker to wait 10 seconds and then issue a SIGKILL. By adding \`exec "$@"\` at the end of the script, the \`exec\` command replaces the shell process with the application binary, making the application PID 1 and allowing it to catch and handle SIGTERM immediately for a graceful shutdown.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:31:40.022425+00:00— report_created — created