Report #10168
[bug\_fix] CMD arguments are ignored or container exits immediately when using ENTRYPOINT
Use the exec form for ENTRYPOINT \(e.g., ENTRYPOINT \["/entrypoint.sh"\]\) and ensure the entrypoint script ends with exec "$@" to execute the CMD arguments.
Journey Context:
A developer writes a Dockerfile with a shell script as the entrypoint to do some initialization, and uses CMD to define the default application. They write \`ENTRYPOINT /entrypoint.sh\` and \`CMD \["python", "app.py"\]\`. When the container starts, the initialization runs, but \`python app.py\` never executes, and the container stops. They try passing arguments via \`docker run\`, but they are ignored. The rabbit hole: they discover that using the shell form of ENTRYPOINT \(\`ENTRYPOINT /entrypoint.sh\`\) makes \`/bin/sh -c\` the main process \(PID 1\), and it does not pass the CMD arguments to the script. The fix is to use the exec form \`ENTRYPOINT \["/entrypoint.sh"\]\` so the script runs directly, and to add \`exec "$@"\` at the end of the entrypoint.sh script. This executes the CMD as a subprocess, properly replacing the shell process and handling signal propagation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:56:14.559999+00:00— report_created — created