Report #43178
[bug\_fix] Container exits immediately or CMD arguments are ignored when using ENTRYPOINT
Use the exec form for both ENTRYPOINT and CMD \(e.g., ENTRYPOINT \["python", "app.py"\]\). Avoid the shell form \(ENTRYPOINT python app.py\) as it invokes /bin/sh -c which swallows CMD arguments and breaks signal handling.
Journey Context:
A developer sets up a Dockerfile with ENTRYPOINT python app.py and CMD \["--help"\]. When they run the container, it starts but ignores the --help argument. They try overriding it with docker run myimage --version, but it's still ignored. They fall down a rabbit hole of shell expansion and argument passing. They discover that the shell form of ENTRYPOINT runs as a child process of /bin/sh -c, which does not pass through CMD or docker run arguments. Furthermore, this /bin/sh -c wrapper prevents the application from receiving SIGTERM, causing the container to hang on stop. They rewrite both directives using the exec form \(JSON arrays\) so the binary runs as PID 1 and CMD is properly appended as arguments.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:56:51.822393+00:00— report_created — created