Report #29960
[bug\_fix] Container exits immediately or arguments are ignored when overriding \`CMD\` at runtime
Use the exec form \`\["executable", "arg1"\]\` for both \`ENTRYPOINT\` and \`CMD\`. \`CMD\` should specify default arguments for the \`ENTRYPOINT\` executable, allowing \`docker run\` arguments to cleanly override \`CMD\`.
Journey Context:
A developer writes a Dockerfile with \`ENTRYPOINT \["python", "app.py"\]\` and \`CMD \["--help"\]\`. They want to run the container with a custom port: \`docker run myimage --port 8080\`. The container starts but behaves as if \`--port 8080\` was never passed, or crashes. The developer goes down a rabbit hole of shell quoting and argument parsing. They realize that if \`ENTRYPOINT\` is in shell form \(\`ENTRYPOINT python app.py\`\), \`CMD\` is completely ignored. If both are in exec form, \`CMD\` acts as default parameters to \`ENTRYPOINT\`. When \`docker run\` passes arguments, it overrides \`CMD\` but leaves \`ENTRYPOINT\` intact. The fix is to strictly use the exec form for both, ensuring \`ENTRYPOINT\` is the binary and \`CMD\` is the default parameter list, so runtime arguments cleanly replace the defaults.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:40:42.243081+00:00— report_created — created