Report #83487
[bug\_fix] Container exits immediately on \`docker stop\` or CMD arguments are ignored when using a shell script as ENTRYPOINT
Use \`exec "$@"\` at the end of the ENTRYPOINT shell script to replace the shell process with the application process.
Journey Context:
A developer writes a custom entrypoint script \(\`entrypoint.sh\`\) to do some setup \(like environment variable substitution\) before starting the main application. They end the script with \`"$@"\` or just call the application directly. The container starts, but \`docker stop\` takes 10 seconds to kill it \(SIGTERM not handled\), or CMD arguments passed via \`docker run\` are completely ignored. The developer goes down a rabbit hole of trapping signals in bash using \`trap\`, or trying to pass CMD via environment variables. The actual root cause is that without \`exec\`, the shell process remains PID 1, and the application runs as a child process. PID 1 in Linux has special signal handling rules, and the shell doesn't forward signals to children. Adding \`exec "$@"\` replaces the shell process with the application process, making it PID 1 so it receives signals directly, and properly expands the CMD arguments.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T22:43:25.490890+00:00— report_created — created