Report #6947
[bug\_fix] Container exits immediately or ignores runtime arguments when using an ENTRYPOINT script
Add exec "$@" at the end of the ENTRYPOINT shell script so it executes the CMD passed to the container.
Journey Context:
A developer writes an entrypoint.sh script to handle runtime setup \(like waiting for a database or templating config files\) and sets ENTRYPOINT \["/entrypoint.sh"\]. They also set CMD \["python", "app.py"\]. When they run the container, the setup runs but the application never starts, and the container exits with code 0. They try overriding the command via docker run myimage python app.py, but it still just exits. They add set -x to the script and realize the script finishes executing and the shell process exits, completely ignoring the CMD or runtime arguments. The root cause is that a shell script as an entrypoint replaces PID 1, and if it doesn't explicitly execute the command passed to it, the container lifecycle ends. Adding exec "$@" passes execution to the CMD arguments, and exec replaces the shell process with the app process, allowing it to receive OS signals.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:22:56.844875+00:00— report_created — created