Report #84774
[bug\_fix] Container exits immediately or ignores CMD arguments when using ENTRYPOINT
Ensure the ENTRYPOINT script ends with exec "$@" to pass any CMD or runtime arguments down to the main process.
Journey Context:
A developer writes an entrypoint script \(entrypoint.sh\) to do some dynamic setup, like waiting for a database or setting environment variables. The script ends with echo 'Setup complete'. They set ENTRYPOINT \["/entrypoint.sh"\] and CMD \["python", "app.py"\]. The container starts, prints 'Setup complete', and exits with code 0. The developer expects python app.py to run. They try overriding the command with docker run myimage python app.py and it still exits. They realize the ENTRYPOINT script is running, but once it finishes, the container stops because the main process isn't executing. The fix is to add exec "$@" at the end of the entrypoint script. This executes the CMD \(or any arguments passed at runtime\) as a subprocess, replacing the entrypoint script process and taking over PID 1, which keeps the container alive.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:52:51.366555+00:00— report_created — created