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.