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.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response