Report #51640
[bug\_fix] Container exits immediately or drops runtime arguments when using a custom ENTRYPOINT script
Add \`exec "$@"\` at the end of the entrypoint shell script to ensure the \`CMD\` or runtime arguments are executed as the main process \(PID 1\).
Journey Context:
A developer writes an \`entrypoint.sh\` script to run database migrations before starting the application. They configure the Dockerfile with \`ENTRYPOINT \["/entrypoint.sh"\]\` and \`CMD \["python", "app.py"\]\`. The container starts, logs show the migrations running successfully, but then the container exits with code 0. The developer assumes the app is crashing silently and adds verbose logging, but the app never starts. They eventually realize the shell script finishes executing and exits, which stops the container because PID 1 is gone. The \`CMD\` arguments were passed to the script as parameters but were never executed. Adding \`exec "$@"\` to the end of the script executes the \`CMD\` arguments, and \`exec\` replaces the shell process with the application so it receives OS signals properly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:10:14.273544+00:00— report_created — created