Use the-v parameter in Docker Practice 2 to associate the host with the related directory in the container (mount), so we can use this channel to place the data that we want to copy with each other so that we can copy the file with the CP command.
In addition to this approach, we can also use different commands to copy the data. copy data from a container like a host
Docker provides the CP command, as follows:
# docker PS
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a77a72ac178c tutum/apache-php:latest "/run.sh" hours ago up hours 0.0.0.0:8080->80/tcp Phpapache_phpapache_1
# docker-enter a77a72ac178c
root@a77a72ac178c:~# ls/var/www/html
index.php logo.png
root@a77a72ac178c:~# exit
Logout
# docker CP a77a72ac178c:/var/www/html/var/www/
# ls/var/www/
app download index.html
# ls/var/www/app/
index.php logo.png
copying data from the host to the container
This is to use a magic channel provided by the Docker to complete the data transfer from the host to the container.
First you get the full ID of the container using the Docker inspect method,
Inspect return low-level information on a container
Then use the/var/lib/docker/aufs/mnt/channel to complete the copy.
Examples are as follows:
# Docker Inspect-f ' {{. Id} ' a77a72ac178c
a77a72ac178c1e35708d2af446197c10239b0b1bd8932104578e334b83eb93a2
# CP docker/ docker-start.sh/var/lib/docker/aufs/mnt/a77a72ac178c1e35708d2af446197c10239b0b1bd8932104578e334b83eb93a2/root/
# docker-enter a77a72ac178c
# pwd
/root
# ls
docker-start.sh