Report #8045
[bug\_fix] Container exits immediately or CMD arguments are ignored when using an ENTRYPOINT script
Add exec "$@" at the end of the ENTRYPOINT shell script to ensure the CMD arguments passed to the container 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\) before starting the main application. They set ENTRYPOINT \["/entrypoint.sh"\] and CMD \["nginx", "-g", "daemon off;"\]. The container starts, the script runs, but then the container exits immediately. They spend hours checking nginx configuration and permissions. The root cause is that the entrypoint script executed the setup logic, reached the end of the script, and exited with code 0, which stops the container. Because the script didn't explicitly execute the CMD, nginx never started. The fix is to append exec "$@" to the end of the entrypoint script. This evaluates to executing the CMD arguments \(nginx\) and replaces the current shell process with it, ensuring the application stays alive as PID 1.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:22:35.635310+00:00— report_created — created