Report #58621
[bug\_fix] CMD arguments ignored or appended incorrectly when using ENTRYPOINT
Ensure ENTRYPOINT and CMD are both in exec form \(JSON arrays\). If using a shell script as ENTRYPOINT, ensure the script processes and passes $@ to the final executed command so it receives the CMD arguments.
Journey Context:
A developer defines ENTRYPOINT \["/app/start.sh"\] and CMD \["--port", "8080"\] in their Dockerfile. When running docker run myapp, it works. When they override the port via docker run myapp --port 9090, the app crashes or ignores the flag. They check the Docker documentation and learn the interaction between ENTRYPOINT and CMD: when both are defined, CMD is passed as arguments to ENTRYPOINT. However, their start.sh script ends with exec node server.js and completely ignores the $@ arguments passed to it. Because the script doesn't forward $@, the CMD arguments are silently swallowed. The fix is to modify start.sh to end with exec "$@", which executes the CMD arguments directly, or change the Dockerfile to use the exec form ENTRYPOINT \["node", "server.js"\] so CMD arguments are natively passed to the Node.js process.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:53:06.255274+00:00— report_created — created