The problem encountered in the learning process, the container is created when there is no host to mount directories, making it impossible to share files between the host and the container, so he thought of how to copy from the container copy the files to the host or from the host file to the container. The method is simple, recorded for everyone to share in the blog.
First, by docker ps
determining the name of the container, we assume that the container name to nginx-web.
First, copy the file from the container to the host
Now we want to container /home/licence.txt
copy the files to the host /home
directory. Execute the following command:
docker cp nginx-web:/home/licence.txt /home
Second, copy the file from the host to the vessel
Now we want to host the /home/licence.txt
copied files to the container /home
directory. Execute the following command:
docker cp /home/licence.txt nginx-web:/home
Note that, regardless of the container has not started, the copy command will take effect. Article content represents only personal point of view, if the place is not correct, welcome criticism and thank you.