Report #77168
[bug\_fix] Container exits immediately or throws 'executable file not found' when passing arguments to a container with a shell ENTRYPOINT
Ensure the ENTRYPOINT script ends with exec "$@" to execute the CMD arguments passed to the container. Use the exec form \(ENTRYPOINT \["/entrypoint.sh"\]\) to ensure signals are handled correctly.
Journey Context:
A developer writes an entrypoint.sh script to perform runtime setup \(like waiting for a database or generating dynamic config\) and defines ENTRYPOINT \["/entrypoint.sh"\]. They define CMD \["python", "app.py"\] expecting the Python app to start after the script finishes. Instead, the container exits cleanly right after the entrypoint script runs, or throws an error about missing executables if they used the shell form ENTRYPOINT. They debug by adding sleep commands and echo statements, confirming the script runs but the app never starts. The rabbit hole leads to Linux process management: when the entrypoint shell script finishes, it exits, and because PID 1 exits, the container stops. The CMD arguments are passed as parameters to the ENTRYPOINT, but the script never executes them. Adding exec "$@" at the end of the script replaces the shell process with the CMD process, allowing the app to run as PID 1 and properly receive OS signals like SIGTERM for graceful shutdowns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:07:18.411135+00:00— report_created — created