I'm trying to figure out the docker for the hundredth time. Now I create spring-boot
simple application and create docker image
for it:
FROM openjdk:8
EXPOSE 8080
ADD /build/libs/hello-docker-0.0.1-SNAPSHOT.jar hello-docker.jar
ENTRYPOINT ["java", "-jar", "hello-docker.jar"]
What did i do step by step:
1) Build my app(as a result, my hello-docker-0.0.1-SNAPSHOT.jar
appeared in the build
folder)
2) moved to the directory where the Docker file
is located and executed the command: docker build -f Dockerfile -t springdocker .
3) Run this image
as container: docker run -p 8080:8080 springdocker
As a result, my application started successfully.
But now I decided to change something in my application. I did it and tried to repeat all the steps. 1-> 2-> error
On 2 stepa new image was created and the old one was in the active state. It turns out that I need to stop the old one and start a new one.
it is not comfortable. I intuitively understand that this is not how it should work. I do not understand how to properly update the container. I constantly change my application and if I need to stop the container then create an image and then launch it - this is not a convenience but a complication. With the same success, I can stop the my application and launch a new one without a docker. I understand that I do not understand how this works, and I want someone to explain to me how to do it.