Report #16574
[bug\_fix] docker stop takes 10 seconds to exit the container, eventually forcefully killing the app with SIGKILL.
Use exec "$@" at the end of the entrypoint script to replace the shell process with the application process, allowing it to receive OS signals directly as PID 1.
Journey Context:
A developer containerizes a Java application. They write an entrypoint.sh script that does some environment variable preprocessing and then runs java -jar app.jar. They notice that docker stop always takes 10 seconds, meaning the container isn't shutting down gracefully. They check the Java app, which handles SIGTERM correctly. They realize that when entrypoint.sh runs the java command, the shell becomes PID 1 and the Java app is a child process. The shell \(PID 1\) does not forward SIGTERM to child processes. By changing the final line of entrypoint.sh to exec "$@" \(and configuring the Dockerfile to CMD \["java", "-jar", "app.jar"\]\), the exec command replaces the shell with Java, making Java PID 1 and allowing it to catch the SIGTERM signal immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:57:13.116410+00:00— report_created — created