Report #2591
[bug\_fix] Container exits immediately or throws 'executable file not found' when passing arguments via docker run, despite CMD being defined.
Use the exec form of ENTRYPOINT and CMD together \(e.g., ENTRYPOINT \["my-app"\] and CMD \["--default-arg"\]\), or change ENTRYPOINT to CMD if arguments should be completely replaced by docker run arguments. Do not use the shell form of ENTRYPOINT if you expect CMD or run arguments to be passed.
Journey Context:
A developer defines \`ENTRYPOINT my-app\` in their Dockerfile and expects \`CMD --help\` to pass the \`--help\` flag to \`my-app\`. The container starts but ignores the flag, or crashes when they run \`docker run my-image --port 8080\` because it tries to run \`--port 8080\` as an executable. They fall down a rabbit hole reading Docker documentation on instruction interaction. They discover that the shell form of ENTRYPOINT \(\`ENTRYPOINT my-app\`\) runs \`/bin/sh -c 'my-app'\`, which completely ignores any CMD or arguments passed via \`docker run\`. The fix is to switch to the exec form \`ENTRYPOINT \["my-app"\]\`, which directly executes the binary and appends CMD or runtime arguments to it. This ensures signals are handled correctly and arguments are passed as expected.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T13:19:11.847249+00:00— report_created — created