Docker Engine 29 reference · Containers
docker cp Command (Docker CLI)
Copy files or folders between a container and the host, in either direction, even when the image has no shell.
Docker Engine 29
Syntax
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH | SRC_PATH CONTAINER:DEST_PATH
Parameters
| Parameter | Description |
|---|---|
-a |
Copy with original ownership (archive mode). |
-L |
Follow symbolic links in the source. |
Examples
docker run -d --name rc-ref-cp alpine:3.24 sleep 300 > /dev/null
echo 'from the host' > note.txt
docker cp note.txt rc-ref-cp:/tmp/note.txt
docker exec rc-ref-cp cat /tmp/note.txt
docker rm -f rc-ref-cp > /dev/null
Output
from the host
Run this on your computer — see “Get Started” for setup.
docker run --name rc-ref-cp2 alpine:3.24 sh -c 'echo report-data > /tmp/report.txt'
docker cp rc-ref-cp2:/tmp/report.txt ./report.txt
cat report.txt
docker rm rc-ref-cp2 > /dev/null
Output
report-data
Run this on your computer — see “Get Started” for setup.
Related
docker exec· Run an extra command inside a running container, for example a shell for debugging or a one-off task.docker inspect· Show the low-level JSON configuration and state of containers, images, volumes or networks; extract fields with --format.