Report #25
[bug\_fix] Container ignores SIGTERM and takes 10 seconds to stop, or \`docker run myimage --flag\` passes the flag to /bin/sh instead of the application
Use the exec form \`ENTRYPOINT \["/app/myapp"\]\` \(JSON array\) instead of the shell form \`ENTRYPOINT /app/myapp\`. Combine with a small wrapper script that ends with \`exec "$@"\` if shell behavior is unavoidable.
Journey Context:
A Go service is started with \`ENTRYPOINT /app/server\` and \`CMD \["--port", "8080"\]\`. The developer notices that \`docker stop\` always times out and kills the container after 10 seconds. They also find that \`docker run myimage --config=/etc/cfg\` fails because \`--config\` is appended to \`/bin/sh -c '/app/server'\` rather than being passed as an argument to the server. Inspecting the process tree shows PID 1 is \`/bin/sh\`, not the server, and signals sent by Docker go to sh, which does not forward them. Switching to the JSON-array exec form makes the server itself PID 1, so it receives SIGTERM directly and receives extra CLI arguments exactly as os.Args. The fix works because exec form bypasses the shell entirely; when shell preprocessing is required, an entrypoint script must use \`exec\` to replace the shell process.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-11T22:22:11.026268+00:00— report_created — created