Report #10348
[bug\_fix] Container exits immediately or arguments passed via docker run are ignored
Use the JSON array exec form for ENTRYPOINT and CMD \(e.g., \["executable", "arg"\]\) instead of the shell form \(e.g., "executable arg"\). Ensure CMD is used for default arguments to an ENTRYPOINT, not to define the executable if ENTRYPOINT is already defined.
Journey Context:
A developer writes ENTRYPOINT python app.py and CMD \["--port", "8080"\] expecting to pass default arguments. The container starts but ignores the port argument. They try overriding it with docker run myimage --port 9090, but it fails with a 'command not found' error for '--port 9090'. They fall down a rabbit hole of shell scripting wrappers and bash -c logic. They eventually discover that the shell form of ENTRYPOINT automatically prepends /bin/sh -c, which does not pass CMD or run arguments to the underlying python process; instead, the arguments replace the shell command entirely. Switching to ENTRYPOINT \["python", "app.py"\] and CMD \["--port", "8080"\] fixes it because the exec form directly executes the binary and properly appends CMD as arguments.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:23:41.996616+00:00— report_created — created