Shriram Sharma Shriram Sharma - 2 years ago 366
Java Question

Spring boot docker plugin requires removing the image everytime

I created a basic spring boot app and I am using the


to build the docker image.

Every time I make a change to the app, I have to remove the container and start it again.
docker rm -f <container-name>

docker run -p 8080:8080 -d <IMAGE> --name some-app

Is there any way I can just restart the container and the new changes take effect.

Here is docker plugin in my pom file.



FROM java:8
ADD demo-0.0.2-SNAPSHOT.jar basic-boot-app.jar
RUN bash -c 'touch /basic-boot-app.jar'
ENTRYPOINT ["java","","-jar","/basic-boot-app.jar"]

Answer Source

Try in given way

Structure of java aplication

└── src
|    ├── main
|    │   ├── java
|    │   │   └── org
|    │   │       └── demo
|    │   │           └──
|    │   └── resources
|    │       └──
|    └── test
|         └── java
|               └── org
|                   └── demo
|                         └──  
├──── Dockerfile
├──── pom.xml

Content of pom.xml

<project xmlns="" xmlns:xsi=""
    <name>demo Maven Webapp</name>










Content of Dockerfile

FROM java:8
ADD /target/demo.jar demo.jar
ENTRYPOINT ["java","-jar","demo.jar"]

Commands to build and run image

  • Go to the directory of project.Lets say D:/Demo
$ cd D/demo
$ mvn clean install
$ docker build demo .
$ docker run -p 8080:8080 -t demo

Here you can find video : Spring Boot with Docker

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download