# docker cp: Copy Files To & From Containers

> How docker cp works: copying files and directories between the host and a container, extracting CI artifacts, and path errors.

Source: https://latchkey.dev/learn/command-reference/docker-cp-command  
Updated: 2026-06-25

Copy files between the host and a container - great for pulling CI artifacts out.

docker cp copies files and directories between a container filesystem and the host. This page covers both directions and the path semantics that trip people up.

## What it does

docker cp moves files between CONTAINER:PATH and a host path, in either direction. It works on running and stopped containers, which makes it a clean way to extract build artifacts in CI.

## Common usage

```Terminal
docker cp web:/app/dist ./dist          # container -> host
docker cp ./config.yml web:/etc/app/    # host -> container
docker cp web:/var/log/app.log ./logs/
```

## Common errors in CI

"no such file or directory" usually means the source path inside the container is wrong - verify with docker exec ls. A trailing-slash subtlety: copying a directory src to dst/ places src inside dst, while dst (no slash) can rename it; be explicit. To extract artifacts from a build container in CI, create the container, docker cp the output, then docker rm it.

## FAQ

### docker cp: Copy Files To & From Containers?

docker cp copies files and directories between a container filesystem and the host. This page covers both directions and the path semantics that trip people up.

### What it does?

docker cp moves files between CONTAINER:PATH and a host path, in either direction. It works on running and stopped containers, which makes it a clean way to extract build artifacts in CI.

### Common errors in CI?

"no such file or directory" usually means the source path inside the container is wrong - verify with docker exec ls. A trailing-slash subtlety: copying a directory src to dst/ places src inside dst, while dst (no slash) can rename it; be explicit.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
