← All notes

Docker cp: copy files between a container and the host

Answer: docker cp copies a file or directory between a container and the local machine. The container can be a running or stopped container. Container paths are relative to the container root directory. Ownership is set to the user and primary group at the destination.

Examples

docker cp ./app.cfg myctr:/etc/app.cfg
docker cp myctr:/var/log/app.log ./app.log

Notes

SRC_PATH or DEST_PATH can be a file or directory. Local machine paths can be an absolute or relative value. docker cp does not create parent directories for DEST_PATH if they do not exist. Specify -L to copy the link target rather than the link. CONTAINER and its path are separated by a colon delimiter.

Reference list

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs, docker container cp; docker/cli, container cp reference. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/docker/cli/master/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker docs, docker container cp; docker/cli, container cp reference. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/docker/cli/master/LICENSE). Copyright Docker, Inc.

Cite this

Permanent ID: iil:note:ryqc8703

iinventedlight. 2026. "Docker cp: copy files between a container and the host." iinventedlight Library, iil:note:ryqc8703, version of 2026-11-18. https://iinventedlight.com/library/notes/docker-cp/. License: CC-BY-4.0.

@misc{iil_note_ryqc8703,
  author = {{iinventedlight}},
  title = {{Docker cp: copy files between a container and the host}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/docker-cp/},
  note = {Permanent ID iil:note:ryqc8703. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-cp.md.