Report #55315
[bug\_fix] Container exits immediately when running 'docker run myimage /bin/bash' or passing CLI arguments
Use ENTRYPOINT for the primary executable and CMD for default arguments. If the executable is defined in CMD, change it to ENTRYPOINT so that 'docker run' arguments override CMD rather than replacing the executable entirely.
Journey Context:
A developer builds a container for a Python script using 'CMD \["python", "app.py"\]'. When they try to debug by running 'docker run myimage /bin/bash', the container exits instantly. They think bash is missing or the entrypoint is crashing. After deep diving into base images and shell formats, they read the Docker documentation on ENTRYPOINT vs CMD. They realize CMD is entirely replaced by the 'docker run' arguments. So '/bin/bash' replaced 'python app.py', but because they didn't pass '-it', bash exited immediately. Switching to 'ENTRYPOINT \["python", "app.py"\]' and 'CMD \["--help"\]' means 'docker run myimage --debug' appends '--debug' to the ENTRYPOINT, executing 'python app.py --debug' as intended, rather than trying to execute '--debug' as a binary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:20:19.871112+00:00— report_created — created