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 transfer files between Docker container and host

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "how to transfer files between the Docker container and the host". In the daily operation, I believe that many people have doubts about how to transfer the files between the Docker container and the host. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to transfer files between the Docker container and the host computer". Next, please follow the editor to study!

1. Start the container first (take the first-mysql container as an example)

Docker start first-mysql

2. View the container ID

Root@kobe:/opt/software/temp/test# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES688e83c55129 mysql "docker-entrypoint.s..." 6 days ago Up 3 seconds 0.0.0.0 3306/tcp first-mysql688e83c55129 3306-> this is the ID of the container

3. Create a new test file to be copied

Sample location and file name / opt/software/temp/test/test.txt

4. Copy to the container

Docker cp / opt/software/temp/test/test.txt 688e83c55129:/test/

5. Enter the container to see if it has been copied.

Docker exec-it 688e83c55129 bash

6. Copy files from the container to the host

Delete the test.txt on the host first, and then

Docker cp 688e83c55129:/test/test.txt / opt/software/temp/test/

At this point, the study on "how to transfer files between the Docker container and the host" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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