beginnerDockerfile Instructions & Multi-Stage Builds

docker stop always takes 10 seconds even though the app shuts down instantly when killed manually

A Spring Boot service has ENTRYPOINT java -jar app.jar (shell form). docker stop always hits the full grace period. Diagnose and fix. Expected reasoning: shell form makes /bin/sh PID 1; SIGTERM is sent to the shell, not forwarded to the java child process, so java never receives the signal and the timeout always expires before SIGKILL. Fix: switch to exec form, ENTRYPOINT ["java","-jar","app.jar"], so java itself is PID 1 and Spring Boot's shutdown hooks run on SIGTERM.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full DevOps Mastery library.

docker stop always takes 10 seconds even though the app shuts down instantly when killed manually

Next Step

Continue to Final image still contains Maven and the full JDK despite 'minimizing' it← Back to all Docker questions