Report #45018
[bug\_fix] docker run my-image echo hello results in the entrypoint script crashing or passing the command as weird arguments, rather than overriding the default command.
Use ENTRYPOINT for the strict executable and CMD for default arguments, or switch entirely to CMD if the main command needs to be easily overridden by \`docker run\` arguments.
Journey Context:
A developer defines a Dockerfile with an ENTRYPOINT script that runs their app, and sets CMD to start a web server. When they run \`docker run my-image bash\` to debug the container, the container crashes immediately. The app's entrypoint tries to execute 'bash' as an argument to the web server, failing. They go down a rabbit hole trying to escape arguments and rewrite the entrypoint script to handle arbitrary commands. The root cause is a misunderstanding of the ENTRYPOINT/CMD interaction: \`docker run \[cmd\]\` overrides CMD, but \*appends\* to ENTRYPOINT. The fix is to use ENTRYPOINT only for the strict initialization script, and CMD for the default executable, or switch entirely to CMD so \`docker run\` can cleanly replace the main process.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:01:45.895689+00:00— report_created — created