Report #72321
[bug\_fix] Container exits immediately or behaves incorrectly when runtime arguments are passed via docker run, overriding expected defaults.
Use ENTRYPOINT for the executable and CMD for default arguments. If using shell form ENTRYPOINT, switch to exec form \["executable", "param1"\] to ensure CMD or runtime arguments are properly appended, or refactor the application to accept arguments correctly.
Journey Context:
A developer builds an image with ENTRYPOINT \["python", "app.py"\] and CMD \["--help"\]. They run the container in production using docker run myimage --port 8080, expecting the app to start on port 8080. Instead, the app crashes or fails to parse arguments. They fall into a debugging rabbit hole checking the Python argument parser. They eventually realize that when both ENTRYPOINT and CMD are defined, CMD is passed as arguments to ENTRYPOINT. Runtime arguments replace CMD entirely. The command executed is python app.py --port 8080, which works. However, in another image, they used the shell form ENTRYPOINT python app.py, which causes Docker to invoke /bin/sh -c, completely ignoring any CMD or runtime arguments. They switch strictly to the exec form ENTRYPOINT \["python", "app.py"\] to ensure predictable argument passing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:58:42.582258+00:00— report_created — created