Report #14229
[bug\_fix] Container exits immediately or behaves unexpectedly when runtime arguments are passed via docker run, or shell form prevents graceful shutdown.
Use ENTRYPOINT \["executable"\] for the main binary and CMD \["default-args"\] for default parameters, using the exec form \[\] to ensure PID 1 signal handling.
Journey Context:
A developer defines CMD python app.py in a Dockerfile. When they run docker run myimage --host 0.0.0.0, the container exits. They realize the shell form makes the command /bin/sh -c "python app.py", and the --host arg is ignored or misinterpreted. They switch to ENTRYPOINT \["python", "app.py"\], but then docker run myimage /bin/bash appends bash as an argument to python instead of replacing it. Furthermore, the shell form prevents SIGTERM from reaching the Python app, causing 10-second timeout delays on docker stop. The fix is the exec form ENTRYPOINT \["python"\] with CMD \["app.py"\]. This allows docker run myimage --host 0.0.0.0 to override CMD, and docker run --entrypoint /bin/bash myimage to override the binary, while keeping PID 1 as the python process for proper signal handling.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:56:25.278539+00:00— report_created — created