Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make the running container into an image by docker

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report