Report #90827
[bug\_fix] Container takes 10 seconds to stop \(SIGTERM ignored\) or CMD arguments are dropped when using ENTRYPOINT
Use the exec form of ENTRYPOINT \(ENTRYPOINT \["/entrypoint.sh"\]\) and add exec "$@" at the end of the entrypoint script to replace the shell process with the actual application, making it PID 1.
Journey Context:
A developer writes an entrypoint.sh script to do dynamic environment variable setup before starting the app. They use ENTRYPOINT /entrypoint.sh and CMD \["node", "app.js"\]. When running docker stop, the container hangs for 10 seconds and gets forcefully killed \(SIGKILL\). Additionally, the node app never actually starts. The rabbit hole leads to Linux signal handling and PID 1. The shell executing the script becomes PID 1, and standard shells \(like /bin/sh\) do not forward OS signals like SIGTERM to child processes, nor do they naturally evaluate Docker CMD arguments as commands. The fix works because exec "$@" executes the CMD arguments, and exec replaces the shell process with the Node.js process, making Node PID 1 so it catches SIGTERM and shuts down gracefully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:02:58.314496+00:00— report_created — created