xxxxxxxxxx
docker cp <containerId>:/file/path/within/container /host/path/target
xxxxxxxxxx
docker cp src/. mycontainer:/target
docker cp mycontainer:/src/. target
xxxxxxxxxx
# container to host
ocker cp <containerId>:/file/path/within/container /host/path/target
# host to container
docker cp /host/local/path/file <containerId>:/file/path/in/container/file
xxxxxxxxxx
for copy file from a container to the host use the command
docker cp <containerId>:/file/path/within/container /host/path/target
You can also use (part of) the Container ID. The following command is equivalent to the first
sudo docker cp 1b4a:/out_read.jpg .
xxxxxxxxxx
docker cp -a <container_name>:<container_path_ex:/home/build/reports/tests/> <destination_path_ex:build/docer-tests>
xxxxxxxxxx
$ docker run -d --name httpd httpd
$ docker exec httpd pwd
/usr/local/apache2
$ docker exec httpd ls
bin
build
cgi-bin
conf
error
htdocs
icons
include
logs
modules
$ docker cp httpd:/usr/local/apache2/conf .