Report #17119
[bug\_fix] Container exits with code 137 after 10 seconds on docker stop, ignoring SIGTERM
Change the CMD or ENTRYPOINT from shell form \(CMD java -jar app.jar\) to exec form \(CMD \["java", "-jar", "app.jar"\]\), or use exec "$@" in entrypoint scripts.
Journey Context:
A developer deploys a Java/Node.js application to production. When scaling down or running docker stop, the container takes exactly 10 seconds to terminate and exits with code 137 \(SIGKILL\). The developer adds explicit signal handlers to the application code to catch SIGTERM and shut down gracefully, but it still gets killed. They inspect the running container and discover that their application is running as PID 7, while /bin/sh is running as PID 1. Because the CMD was written in shell form, /bin/sh becomes PID 1, and /bin/sh does not forward signals like SIGTERM to child processes. By switching the CMD to exec form \(JSON array format\), the application directly replaces /bin/sh as PID 1 and receives the SIGTERM signal immediately, allowing for sub-second graceful shutdowns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:27:21.197353+00:00— report_created — created