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_PATH

Parameters & Attributes

NameTypeDescription
SRC_PATHpathSource path on the client or container.
DEST_PATHpathDestination path on the other side.
CONTAINERstringContainer 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
Docker Reference