Docker Community Forums

Share and learn in the Docker community.

Redeploy spring-boot application in docker container?

Hi all,

I have a spring-boot project and I want automatically redeploy my jar in the container.
How to do it correctly?
So far, all I see is this way. It’s the right way?

# cd /home/jdev; 
# sudo docker stop ca_spring_boot;
# sudo docker rm ca_spring_boot;  
# sudo docker rmi ca_app_image; 
# sudo docker build -t ca_app_image .;
# sudo docker run -d -p 8888:8080 --name ca_spring_boot ca_app_image

And my Dockerfile
FROM java:8

VOLUME /tmp
EXPOSE 8080
ADD docker-storage/jenkins/workspace/CA/build/libs/ca-1.0.jar app.jar
RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=container","-jar","/app.jar"]

Thanks.

Well I don’t know why you are removing the image ca_app_image, it is better to use tags and create new tag ( version ) of images. And I also recommend you to apply a/b deployment , have a look to this section of the doc https://docs.docker.com/engine/reference/commandline/service_update/#/perform-a-rolling-restart-with-no-parameter-changes
Well I think this is a good tutorial https://docs.docker.com/engine/swarm/swarm-tutorial/rolling-update/

@jsoler has the right idea generally. You need to make a new image with the updated artifact and replace the running container instance with another container using the updated / uniquely tagged image. This is one reason I like the swarm mode / docker service commands, it will roll out a new image to a running service easily by doing docker service update --image.

Thanks for the answers.

Here is the good and working solution
http://stackoverflow.com/questions/41998862/redeploy-spring-boot-application-in-docker-container