<p>I've implemented graceful shutdown logic in my Spring application and it works locally if I send a SIGTERM to the Java process. </p>

<p>However when I'm running it in Kubernetes if I delete the pod or deploy a new one, the logic is not running. First I thought that it's sending SIGKILL instead of SIGTERM but as I've researched, the Docker CMD gets the SIGTERM but does not delegate it to the application. How should I run it correctly?</p>

<p>Right now I'm using this command in my Dockerfile:</p>

<pre><code>CMD [ "java", "-jar", "/app.jar" ]
</code></pre>

OCPi
<p>You could try <a href="https://github.com/Yelp/dumb-init#dumb-init" rel="nofollow noreferrer">dumb-init</a> or something similar. The README at the given link elaborates a bit on "Why you need an init system".</p>
