Skip to content

Docker Copying

We are able to use the docker CLI to copy files to and from containers

Get running containers

From container to host

Using the ID of the container we can copy from inside the container to the host

docker cp <id of container>:/<path/in/container> .
docker cp db129cf0407d:/home/app/podinfo .

From host to container

docker cp </path/on/host> <id of container>:/<path/in/container>
docker cp . db129cf0407d:/root/

From container to container

This is not supported

You will get the below error

copying between containers is not supported

Workaround

We can copy it to local and then copy it to the other container

docker cp <id of container>:/<path/in/container> . && cp <files from container 1> <id of container>:/<path/in/container>
docker cp db129cf0407d:/home/app/podinfo . && docker cp podinfo dd5e23474b51:/root/

Want to make this site better? Open a PR or help fund hosting costs