http://blog.csdn.net/yangzhenping/article/details/43667785
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 to mount the host data volume into the container (you need to specify the mount directory when you Docker run to create the container)
[plain] view plain copy docker run-v/path/to/hostdir:/mnt $container (image name or image ID)
Copy cp/mnt/sourcefile/path/to/destfile inside the container
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/f ile/
Or
[plain] view plain copy docker exec-it <container_id> bash-c ' cat >/path/to/container/file ' </pat h/to/host/file/
Docker can support the mounting of a directory on a host to a mirror.
Docker Run-it-v/home/dock/downloads:/usr/downloads Ubuntu64/bin/bash
With the-v argument, the host directory is preceded by a colon and must be an absolute path, followed by a colon-mounted path within the mirror.
You can now share files from the host in the mirror.
The path permission for the default mount is read-write. If specified as read-only can be used: RO
Docker Run-it-v/home/dock/downloads:/usr/downloads:ro Ubuntu64/bin/bash