Report #8233
[bug\_fix] Docker container runs but application doesn't start; CMD arguments are ignored or swallowed by ENTRYPOINT
If using a custom entrypoint script, ensure it ends with exec "$@" to execute the CMD arguments. Alternatively, use the exec-form JSON array for ENTRYPOINT and CMD to avoid shell processing confusion.
Journey Context:
A developer defines an ENTRYPOINT \["/init-script.sh"\] to set up environment variables, and CMD \["nginx", "-g", "daemon off;"\] to start the web server. The container starts, the script runs, but nginx never starts, and the container exits. They try passing arguments via docker run, but they are ignored. They debug by running the script manually and it works. The issue is that when both ENTRYPOINT and CMD are defined, CMD is passed as arguments to the ENTRYPOINT. The init-script.sh receives nginx and -g as arguments \($1, $2\) but never executes them. The script simply exits, causing the container to stop. Adding exec "$@" at the end of the init-script.sh tells the shell to execute the passed arguments, effectively handing off process execution to the CMD.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:59:52.955517+00:00— report_created — created