1. Copy files from the container to the host?
Answer: Execute the following command in the host
docker cp container name: the path of the file to be copied in the container The corresponding path to be copied to the host
Example: Assuming the container name is testtomcat, the file path to be copied from the container is: /usr/local/tomcat/webapps/test/js/test.js, and now you need to copy test.js from the container to the / of the host Under the opt path, how should the command be written?
Answer: Execute the command on the host
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
docker cp file path to be copied container name: to be copied to the corresponding path in the container
Example: Suppose the container name is 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, then how to write the command?
Answer: Execute the following command on the host
docker cp /opt/test.js testtomcat:/usr/local/tomcat/webapps/test/js
3. A question is being recorded here, how to see the container name?
Execute the command: docker ps, as shown in the figure, where NAMES is the container name.