Report #86921
[bug\_fix] Container exits immediately with code 0 when using an ENTRYPOINT script with CMD
Add exec "$@" at the end of the entrypoint shell script to ensure the CMD arguments are executed as the main process \(PID 1\).
Journey Context:
A developer writes an entrypoint.sh script to perform runtime configuration \(like replacing environment variables in a config file\) and sets it as ENTRYPOINT \["/entrypoint.sh"\]. They also define CMD \["node", "server.js"\]. The script runs successfully, but the container exits immediately instead of keeping the Node.js server running. The developer discovers that the shell script executed but never handed off execution to the CMD. Because the script didn't execute the CMD, the shell process exited, causing PID 1 to terminate and the container to stop. Adding exec "$@" at the end of the entrypoint script executes the CMD as a subprocess, replacing the shell process and properly forwarding signals.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:29:14.773628+00:00— report_created — created