Report #75960
[bug\_fix] Container exits immediately with code 0 or passes wrong arguments when trying to pass runtime arguments via docker run myimage arg
If using ENTRYPOINT, ensure CMD is used for default arguments. If CMD is used alone, remember docker run arguments replace CMD entirely, they do not append. Always use the exec form \["binary", "arg"\] to ensure proper signal handling.
Journey Context:
A developer sets ENTRYPOINT \["python"\] and CMD \["app.py"\]. They want to run a different script and execute docker run myimage debug.py. It works perfectly. Later, they refactor the Dockerfile to use only CMD \["python", "app.py"\] \(no entrypoint\). When they run docker run myimage debug.py, it fails because Docker replaces CMD entirely with 'debug.py', executing 'debug.py' directly \(which might lack a shebang\) instead of 'python debug.py'. They debug by printing the process arguments and realize the difference: CMD is fully replaced by docker run arguments, while ENTRYPOINT uses them as parameters. They revert to ENTRYPOINT \["python"\] and CMD \["app.py"\] to get the desired parameterized behavior.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:05:42.663805+00:00— report_created — created