Report #1302
[bug\_fix] ENTRYPOINT script runs but CMD or docker run arguments are ignored / container exits prematurely
Append \`exec "$@"\` to the end of the shell script used as ENTRYPOINT 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 perform runtime configuration \(like setting dynamic environment variables or waiting for a database\) before starting the main application. They define \`ENTRYPOINT \["/entrypoint.sh"\]\` and \`CMD \["node", "app.js"\]\`. The container starts, the script runs, but the Node.js application never starts, and the container exits. The developer assumes the CMD is being overridden and tries passing the command via \`docker run\`, but it is still ignored. They discover that when a shell script is the ENTRYPOINT, it replaces PID 1, and if the script doesn't explicitly execute the arguments passed to it \(which are the CMD\), the script just exits. Adding \`exec "$@"\` at the end of the script executes the CMD arguments, and using \`exec\` replaces the shell process with the application process, allowing it to receive OS signals properly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-14T15:40:48.741560+00:00— report_created — created