Report #87186
[bug\_fix] Passing arguments to \`docker run\` overrides the entire command instead of appending arguments, or causes the container to exit immediately with an execution error.
Define the executable with \`ENTRYPOINT\` and default arguments with \`CMD\` \(in exec form \`\["arg1", "arg2"\]\`\), or ensure \`CMD\` is used if the entire command is meant to be easily overridden.
Journey Context:
A developer defines a Dockerfile with \`CMD \["python", "app.py"\]\`. They want to pass an argument to the script, so they run \`docker run myimage --debug\`, but the container crashes because it tries to run \`--debug\` as a command, overriding \`python app.py\`. They then switch entirely to \`ENTRYPOINT \["python", "app.py"\]\`, but find they can no longer easily drop into a shell with \`docker run myimage bash\` because it runs \`python app.py bash\`. The rabbit hole involves misunderstanding Docker's instruction interaction. The fix works because it aligns with Docker's strict model: \`ENTRYPOINT\` defines the immutable executable, while \`CMD\` defines default parameters that are naturally overridden by arguments passed to \`docker run\`. Using \`ENTRYPOINT \["python", "app.py"\]\` and \`CMD \["--help"\]\` allows \`docker run myimage --debug\` to correctly execute \`python app.py --debug\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:55:51.108501+00:00— report_created — created