How to make the running container into an image by docker
What this article shares with you is about how docker makes the running container into a mirror image. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
How does docker mirror the running container? The image of the container is static, and each layer of the image is only readable. To create a container through the image is to add a read-write layer to the image. Let's talk about how to build your own docker container image.
1. Upload the jar package to the linux server / usr/local/dockerapp directory and create a file named Dockerfile in the directory where the jar package is located.
2. Add the following to Dockerfile
Specify java8 environment image FROM java:8 copy file to container app-springbootADD docker-springboot-0.0.1.jar / app-springboot.jar declaration startup port number EXPOSE 8080 configure the command ENTRYPOINT to be executed after container startup ["java", "- jar", "/ app-springboot.jar"]
3. Use the docker build command to build an image
Docker build-t docker-springboot-0.0.1.
Format: docker build-t image name: relative position of label Dockerfile
Docker run-p 8080 docker-springboot-0.0.1.
Restart systemctl restart docker
Turn off Firewall systemctl stop firewalld
In addition, you can download the image from the Docker Registry using the command docker pull command, and after executing this command, Docker downloads the latest version of the Java image from the java repository in Docker Hub.
This is how docker mirrors the running container. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.