File copy between container and host (host)

http://www.cnblogs.com/lemonbar/p/4060136.html 1. Use the docker cp command


from the container to the host

docker cp <containerId>:/file/path/within/container /host/path/target

For example, after installing mysql, copy it to my.cnf
docker cp 088ea61c775a:/etc/my.cnf /home/pandy/docker/mysql/



2. 从 主机(host) 到 container
Get container name or short container id :
docker ps
Get full container id
docker inspect -f '{{.Id}}' SHORT_CONTAINER_ID-or-CONTAINER_NAME

copy file :
sudo cp path-file-host /var/lib/docker/aufs/mnt/FULL_CONTAINER_ID/PATH-NEW-FILE

EXAMPLE :

$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

$sudo cp file.txt /var/lib/docker/aufs/mnt/d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5/root/file.txt

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326764204&siteId=291194637