LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

docker-cp

copy files between containers and the host

TLDR

Copy file from container to host
$ docker cp [container]:[/path/to/file] [/local/path]
copy
Copy file from host to container
$ docker cp [/local/file] [container]:[/path/in/container]
copy
Copy directory recursively
$ docker cp [container]:[/path/to/dir] [/local/dir]
copy
Copy preserving ownership
$ docker cp -a [container]:[/path] [/local/path]
copy

SYNOPSIS

docker cp [options] container:srcpath destpathdocker cp [options] srcpath container:destpath

DESCRIPTION

docker cp copies files or directories between a container's filesystem and the local host filesystem, functioning bidirectionally for both container-to-host and host-to-container transfers. This command works with both running and stopped containers, making it useful for extracting logs, injecting configuration files, or backing up data.The command uses tar internally for efficient transfer, streaming data between the container and host. Archive mode (-a) preserves file ownership and permissions, which is important when copying system files or maintaining consistent file attributes.Unlike volume mounts which are configured at container creation, docker cp enables ad-hoc file transfer at any time during a container's lifecycle.

PARAMETERS

-a, --archive

Archive mode (copy all uid/gid information).
-L, --follow-link
Follow symbolic links in source path.
-q, --quiet
Suppress progress output.

INSTALL

sudo apt install docker-cli
copy
sudo dnf install docker-cli
copy
sudo pacman -S docker
copy
sudo apk add docker-cli
copy
sudo zypper install docker
copy
brew install docker
copy
nix profile install nixpkgs#docker
copy

SEE ALSO

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid