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 does docker copy images and containers

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "how to copy images and containers by docker". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to copy images and containers by docker.

How does docker copy images and containers? In docker containers, both the copy image and the copy container are done by saving as a new image.

Save Mirror

Docker save ID > xxx.tardocker load

< xxx.tar 保存容器 docker export ID >

Xxx.tardocker import xxx.tar containr:v1

Then docker run-it containr:v1 bash

If the log files generated after the project is run, we want to view them locally, then we need to copy the generated log files to the local machine.

Start the container service first

Docker run-d-p 8888purl 8080 jpress

Then go inside the container and find the location of the jpress.war file

Docker exec-it 39d439619755 bash

Switch the docker terminal directory

Find the directory where the jpress.war package is located, and then copy the file to the command of the Dockerfile file. First, let's take a look at the Dockerfile directory: / d/java_dev/Docker Toolbox. We change the directory of the docker terminal to the Dockerfile directory.

Start copying files

Docker cp 39d4396197558:/usr/local/tomcat/webapps/jpress.war.

39d4396197558 refers to the ID or name of the container

/ usr/local/tomcat/webapps/jpress.war is the location of the file in the container, indicating that it is copied to the current directory

At this point, I believe you have a deeper understanding of "how to copy images and containers in docker". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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