Report #64283
[bug\_fix] Container exits immediately with code 0 when running \`docker run my-image\`, ignoring CMD arguments.
Add \`exec "$@"\` at the end of the entrypoint shell script to execute the CMD passed to the container, ensuring the entrypoint process is replaced by the long-running CMD process.
Journey Context:
A developer writes an entrypoint script \(\`entrypoint.sh\`\) to perform runtime setup like waiting for a database and setting environment variables. They set \`ENTRYPOINT \["/entrypoint.sh"\]\` and \`CMD \["python", "app.py"\]\`. The container starts, runs the setup, and exits with code 0. The developer thinks the Python app is crashing, but \`docker logs\` shows nothing from Python. They debug by running \`docker run my-image python app.py\` interactively and it works. The root cause is that when Docker runs the entrypoint, if the entrypoint script finishes and exits, the container stops—even if a CMD was provided. The CMD was passed as arguments to the entrypoint script but was never executed. The fix works because \`exec "$@"\` executes the arguments passed to the script \(the CMD\) and uses \`exec\` to replace the current shell process with the Python process, making it PID 1 and keeping the container alive.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:23:05.864298+00:00— report_created — created