Report #75204
[bug\_fix] Container exits immediately or runtime arguments ignored when combining ENTRYPOINT and CMD
If using a shell script as ENTRYPOINT, ensure it ends with \`exec "$@"\` to pass execution to the CMD arguments. If ENTRYPOINT is an executable, define CMD as a JSON array of default arguments \(e.g., \`CMD \["--default-flag"\]\`\).
Journey Context:
A developer writes a Dockerfile with \`ENTRYPOINT \["/entrypoint.sh"\]\` to setup environment variables, and \`CMD \["nginx", "-g", "daemon off;"\]\` to start the web server. The container starts and immediately exits with code 0. They spend hours debugging nginx configuration, thinking it's crashing. They override the entrypoint and see nginx works fine. They finally add logging to \`entrypoint.sh\` and realize the script runs to completion and exits, never actually starting nginx. In Docker, ENTRYPOINT and CMD are concatenated together, but if the entrypoint script doesn't explicitly execute the command passed to it, the container just stops. The fix works because \`exec "$@"\` executes the arguments provided by CMD \(or via \`docker run\`\), replacing the shell process with the intended application so it becomes PID 1 and receives signals correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:49:24.445821+00:00— report_created — created