Report #70223
[bug\_fix] Container exits immediately when overriding command via docker run
Add \`exec "$@"\` at the end of the entrypoint script to ensure arguments passed via CMD or \`docker run\` are executed as the main process.
Journey Context:
A developer creates an entrypoint script to handle runtime environment variable substitution or setup tasks. They define \`ENTRYPOINT \["/entrypoint.sh"\]\` and \`CMD \["python", "app.py"\]\`. The script runs setup but the container exits. They try running \`docker run myimage bash\` to debug, but that also exits instantly. The issue is that the entrypoint script executes its setup commands and then finishes, causing the container to stop because PID 1 exited. It completely ignores the \`CMD\` or the runtime arguments. Adding \`exec "$@"\` tells the shell to execute the arguments passed to the script \(which Docker injects as CMD\) and replace the current shell process with it, keeping the container alive.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:27:08.023550+00:00— report_created — created