Report #64478
[bug\_fix] Container exits immediately or ignores runtime arguments when overriding CMD via docker run
Ensure the ENTRYPOINT script ends with \`exec "$@"\` to execute the CMD or runtime arguments, or restructure the Dockerfile to use CMD instead of ENTRYPOINT if the command should be easily overridable.
Journey Context:
A developer writes an entrypoint script that does environment setup \(waiting for a DB, setting dynamic env vars\) and sets \`ENTRYPOINT \["/entrypoint.sh"\]\` and \`CMD \["python", "app.py"\]\`. When they run \`docker run myimage python debug.py\`, the container starts, runs the setup, but then exits without running \`debug.py\`. They debug by adding \`echo\` statements, seeing the script simply ends. They realize the entrypoint script consumed the execution flow but didn't hand off to the CMD arguments. Because Docker passes the CMD as arguments to the ENTRYPOINT, the script receives \`python debug.py\` as \`$@\`, but ignores them. Adding \`exec "$@"\` at the end of the script ensures the setup runs first, and then the process seamlessly transitions to the intended command, replacing the script as PID 1.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:42:50.514423+00:00— report_created — created