Report #84113
[bug\_fix] Running docker run my-image bash or passing arguments immediately exits the container or throws an error, rather than overriding the command
If the container needs to accept arbitrary commands at runtime, use CMD instead of ENTRYPOINT, or ensure the ENTRYPOINT script uses exec "$@" to pass arguments to the shell.
Journey Context:
A developer builds a web server image using ENTRYPOINT \["node", "server.js"\]. Later, they need to debug the container and run docker run -it my-image bash. The container exits instantly. They think bash isn't installed, so they modify the Dockerfile to install bash, but it still exits. The rabbit hole: they try different base images. The root cause is that when both ENTRYPOINT and CMD \(or run arguments\) are defined, the CMD/run arguments are appended to the ENTRYPOINT. The container actually ran node server.js bash. Using exec "$@" in an entrypoint script allows the script to process the passed arguments, or switching to CMD allows the run command to completely override the default.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T23:46:37.277499+00:00— report_created — created