Reuse spring-boot app in docker container?

I have a spring-boot project and I want to automatically redistribute my jar in the container. How to do it right? So far, everything that I see is so. Is this 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.

+5
source share
2 answers

You can set the volume and place the app.jar application there. Therefore, you do not need to restore the image, you just restart the container.

Dockerfile

 FROM java:8 ENTRYPOINT [ "sh", "-c", "java -jar /mnt/app.jar" ] 

Put your app.jar in / docker / spring /

Build and run:

 docker build -t spring_test . docker run -d -v /docker/spring/:/mnt -p 12384:8080 --name spring_test_running spring_test 

If you update the spring application you simply run:

 docker restart spring_test_running 
+6
source

The previous answer is good. But there is a need to restart the container every time you want to test your code. But we can avoid this problem. Just use the Spring dev tool and set the target directory as described above.

+1
source

Source: https://habr.com/ru/post/1263724/


All Articles