[Docker] Copy files from the container to the host or copy files from the host to the docker container

1. Copy files from the container to the host machine?

     Answer: Execute the following command in the host machine

docker cp container name: the path of the file to be copied in the container to be copied to the corresponding path of the host machine 

     Example: Assuming that the container name is testtomcat, the file path to be copied from the container is: /usr/local/tomcat/webapps/test/js/test.js, now test.js is copied from the container to the host machine / Below the opt path, how should the command be written?

     Answer: Execute commands on the host machine

docker cp testtomcat:/usr/local/tomcat/webapps/test/js/test.js /opt

  

2. Copy files from the host to the container

      Answer: Execute the following command in the host machine

docker cp file path to be copied container name: to be copied to the corresponding path in the container

       Example: Assuming that the container is named testtomcat, and now you want to copy the host /opt/test.js file to the / usr / local / tomcat / webapps / test / js path in the container, how do you write the command?

       Answer: Execute the following command on the host machine     

docker cp /opt/test.js testtomcat:/usr/local/tomcat/webapps/test/js

 

Published 190 original articles · praised 497 · 2.60 million views +

Guess you like

Origin blog.csdn.net/u013066730/article/details/105494982