I am running a dropwizard Java application in a Docker container using the image java:7u79
based on debian/jessie
.
My Java application handles the SIGTERM
signal to shutdown gracefully. The SIGTERM
handling works perfect when I run the application without Docker.
When I run it in a Docker container the SIGTERM
does not reach the Java application when I issue a docker stop
command. It kills the process abruptly after 10 seconds.
My Dockerfile
:
FROM java:7u79
COPY dropwizard-example-1.0.0.jar /opt/dropwizard/
COPY example.keystore /opt/dropwizard/
COPY example.yml /opt/dropwizard/
WORKDIR /opt/dropwizard
RUN java -jar dropwizard-example-1.0.0.jar db migrate /opt/dropwizard/example.yml
CMD java -jar dropwizard-example-1.0.0.jar server /opt/dropwizard/example.yml
EXPOSE 8080 8081
What is wrong with this Dockerfile
? Is there any other way to tackle this problem?