Docker host and container (container) Copy the method of transferring files to each other __docker

Source: Internet
Author: User
Tags docker cp

Reprint please indicate the source: http://blog.csdn.net/dongdong9223/article/details/71425077
This article comes from "I'm a fish on the hook" blog.

I've explained how to get in and out of Docker's container. Today, in Docker, the host and container (container) Copy the method of transferring files to each other. 1 copy files from container to host

Copy mode is:

Docker CP container name: The file name and its path to be copied in the container should be copied to the corresponding path in the host.

For example, the container:

MyContainer

Path in:

/opt/testnew/

Files under:

File.txt

Copy to host:

/opt/test/

Path, the following commands are executed in the hosting host:

Docker CP mycontainer:/opt/testnew/file.txt/opt/test/
2 Copy files from host to container

Copy mode is:

Docker the file name to be copied in the CP host and its path container name: the corresponding path to be copied to the container

For example, the path to the host hosts:

/opt/test/

Files under:

File.txt

Copy to Container:

MyContainer

Of

/opt/testnew/

Path, the same commands are executed in the host computer as follows:

Docker Cp/opt/test/file.txt mycontainer:/opt/testnew/
3 The Copy command will take effect regardless of whether the container is activated.

Note that the copy command takes effect regardless of whether the container is started or not.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.