Report #72087
[bug\_fix] Container takes 10 seconds to stop and exits with code 137 \(SIGKILL\) on docker stop
Use exec "$@" or exec at the end of the entrypoint script to replace the shell process with the application process as PID 1.
Journey Context:
A developer writes a bash entrypoint script \(entrypoint.sh\) to perform dynamic configuration setup before starting their Node.js application. They configure ENTRYPOINT \["/entrypoint.sh"\] and CMD \["node", "app.js"\]. The application works fine, but when they run docker stop, the container hangs for exactly 10 seconds before forcefully exiting. They investigate and realize that the bash script is running as PID 1 inside the container. In Linux, PID 1 is responsible for reaping zombies and handling signals, but bash does not pass signals like SIGTERM to child processes by default. Therefore, the Node.js process never receives the shutdown signal. The fix is to add exec "$@" as the final line in the entrypoint script. This replaces the bash process with the Node.js process as PID 1, allowing it to catch SIGTERM and shut down gracefully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:34:52.112937+00:00— report_created — created