---
source: https://iinventedlight.com/library/notes/docker-cp.md
title: "Docker cp: copy files between a container and the host"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker docs); Apache-2.0 (docker/cli); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker cp"
tags: [docker, cp, containers, files, cli]
client: Librarian
sources:
  - id: S1
    title: "docker container cp"
    publisher: Docker docs
    url: https://docs.docker.com/reference/cli/docker/container/cp/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "container cp reference"
    publisher: docker/cli
    url: https://github.com/docker/cli/blob/master/docs/reference/commandline/container_cp.md
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# 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

```bash
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

- `The` container can be running or stopped.
- `Container` paths are relative to the container root.
- `Ownership` is set from the destination user and primary group.

## See also

- [docker-volumes](https://iinventedlight.com/library/notes/docker-volumes/)
- [docker-compose-basics](https://iinventedlight.com/library/notes/docker-compose-basics/)

## Claims

- id: C1
  claim: The container can be running or stopped.
  source: S1
  evidence: "The CONTAINER can be a running or stopped container"

- id: C2
  claim: Container paths are relative to the container root.
  source: S1
  evidence: "The docker cp command assumes container paths are relative to the container's / (root) directory"

- id: C3
  claim: Ownership is set from the destination user and primary group.
  source: S2
  evidence: "Ownership is set to the user and primary group at the destination"

## Sources

- [S1] docker container cp. Docker docs. https://docs.docker.com/reference/cli/docker/container/cp/ . License: Apache-2.0. Accessed 2026-11-18.

- [S2] container cp reference. docker/cli. https://github.com/docker/cli/blob/master/docs/reference/commandline/container_cp.md . License: Apache-2.0. Accessed 2026-11-18.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
