From: http://blog.csdn.net/yangzhenping/article/details/43667785 Click Open link
How to copy data inside and outside the Docker container.
Copy files from the container to the host [plain] view plain copy docker CP <containerid>:/file/path/within/container/host/path/target
Copy files from host to container
Reference from:
Http://stackoverflow.com/questions/22907231/copying-files-from-host-to-docker-container
1. Use-V Mount host data volume to container
[Plain] View plain copy docker run-v/path/to/hostdir:/mnt $container copy in Container Cp/mnt/sourcefile/path/to/destfile
2. Copy to the container physical storage system directly on the host
A. Get the container name or ID:
[Plain] View plain copy $ docker PS
B. Get the ID of the entire container
[Plain] View plain copy $ docker inspect-f ' {{. ID} ' Step a gets the name or ID
C. Copy files on the host:
[Plain] View plain copy $ sudo cp path-file-host/var/lib/docker/aufs/mnt/full_container_id/path-new-file or $ sudo CP Path-file-host/var/lib/docker/devicemapper/mnt/123abc<<id>>/rootfs/root
Example:
[plain] View plain copy $ docker ps container id image command created STATUS PORTS NAMES D8e703d7e303 solidleon/ssh:latest /usr/sbin/sshd -D cranky_pare $ docker inspect -f ' {{. Id} ' cranky_pare or $ docker inspect -f ' {{. Id} ' d8e703d7e303 d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5 $&NBSP;SUDO&Nbsp;cp file.txt /var/lib/docker/aufs/mnt/** d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5
3. With the input output character
[Plain] View plain copy docker run-i ubuntu/bin/bash-c ' cat >/path/to/container/file ' </path/to/host/file/
Or
[Plain] View plain copy docker exec-it <container_id> bash-c ' cat >/path/to/container/file ' </path/to/ho st/file/