# docker cp Command Reference

> Reference for docker cp in CI: copy files and directories between a container and the host, for extracting build artifacts or test reports in pipelines.

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

Copy files between a container and the host.

docker cp moves files or directories between a container filesystem and the host in either direction. In CI it extracts artifacts such as compiled binaries, coverage reports, or screenshots from a container so a later step can upload them.

## Common flags

- `docker cp CONTAINER:SRC DEST` - copy from container to host
- `docker cp SRC CONTAINER:DEST` - copy from host to container
- `-a, --archive` - preserve uid/gid and permissions
- `-L, --follow-link` - follow symlinks in the source

## Example

```shell
docker cp app-tests:/app/coverage ./coverage
docker cp ./config.json app-web:/etc/app/config.json
```

## In CI

After a containerized test run, docker cp the reports directory out to the workspace, then upload it as an artifact. cp works on stopped containers too, so you can extract output even from a container that has exited.

## FAQ

### docker cp Command Reference?

docker cp moves files or directories between a container filesystem and the host in either direction. In CI it extracts artifacts such as compiled binaries, coverage reports, or screenshots from a container so a later step can upload them.

### In CI?

After a containerized test run, docker cp the reports directory out to the workspace, then upload it as an artifact. cp works on stopped containers too, so you can extract output even from a container that has exited.

---

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
