Report #16167
[bug\_fix] Container exits immediately or ignores runtime arguments passed to ENTRYPOINT
Ensure the entrypoint script ends with \`exec "$@"\` to execute the command passed as arguments \(from CMD or docker run\) within the script's process.
Journey Context:
A developer creates an entrypoint script \(\`entrypoint.sh\`\) to perform runtime configuration like setting dynamic environment variables or waiting for a database. They set \`ENTRYPOINT \["/entrypoint.sh"\]\` and \`CMD \["nginx", "-g", "daemon off;"\]\`. The container starts, the script runs, but then exits immediately with code 0, and Nginx never starts. They try passing different commands via \`docker run\`, but they are all ignored. The developer realizes the shell script executed its setup tasks and then simply finished, causing PID 1 to exit and the container to stop. The \`CMD\` or runtime arguments were never executed. Adding \`exec "$@"\` works because it takes the arguments passed to the entrypoint \(\`$@\`\), uses \`exec\` to replace the current shell process with that command, and makes it PID 1, ensuring the application receives signals correctly and keeps the container alive.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:56:30.248937+00:00— report_created — created