Report #59942
[bug\_fix] Container exits immediately or CMD arguments are ignored when both ENTRYPOINT and CMD are defined in the Dockerfile.
Ensure the ENTRYPOINT script ends with \`exec "$@"\` to execute the CMD arguments passed to it, or restructure the Dockerfile to use only ENTRYPOINT or only CMD as appropriate.
Journey Context:
A developer defines an initialization script as \`ENTRYPOINT \["/init-script.sh"\]\` and the primary service as \`CMD \["nginx", "-g", "daemon off;"\]\`. The container starts, runs the script, and exits with code 0. The developer spends hours debugging nginx configuration, thinking it's crashing. They eventually inspect the container logs and see no nginx output. They realize Docker passes the CMD as arguments to the ENTRYPOINT. Since the bash script \`/init-script.sh\` runs to completion and exits, it never starts nginx. The shell script receives \`nginx -g daemon off;\` as arguments but ignores them. Adding \`exec "$@"\` at the end of the script replaces the shell process with the process specified by CMD, ensuring nginx receives the signals and stays running.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T07:06:12.554284+00:00— report_created — created