Docker CLI
docker cp
Copies files or directories between a container and the client filesystem, including supported paths in stopped containers. Parent directories must exist; destination behavior depends on path type, and files can be overwritten. It is not ongoing synchronization or a consistent database backup. Use a fresh destination in a disposable lab. Requires the bm-v04-copy fixture and lab directory from the lesson. The local path belongs to the CLI machine; copying can overwrite files. Verify contents before deleting lab copies.
Formal Syntax & Structure
docker syntaxdocker
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATHdocker cp [OPTIONS] SRC_PATH CONTAINER:DEST_PATHParameters & Attributes
| Name | Type | Description |
|---|---|---|
| SRC_PATH | path | Source path on the client or container. |
| DEST_PATH | path | Destination path on the other side. |
| CONTAINER | string | Container name or ID, followed by a colon and path. |
Working Example
Example Snippetdocker
docker cp "$lab_dir/note.txt" bm-v04-copy:/tmp/note.txt