LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

kubectl-cp

copies files and directories between local filesystem and containers in pods

TLDR

Copy file to pod
$ kubectl cp [localfile] [pod-name]:[/path/in/container]
copy
Copy file from pod
$ kubectl cp [pod-name]:[/path/in/container] [localfile]
copy
Copy to specific container
$ kubectl cp [localfile] [pod-name]:[path] -c [container]
copy
Copy entire directory
$ kubectl cp [localdir] [pod-name]:[/remote/dir]
copy
Copy from pod in specific namespace
$ kubectl cp [namespace]/[pod-name]:[/path/in/container] [localfile]
copy
Copy without preserving permissions
$ kubectl cp [localfile] [pod-name]:[path] --no-preserve
copy

SYNOPSIS

kubectl cp src dest [options]

DESCRIPTION

kubectl cp copies files and directories between local filesystem and containers in pods. Uses tar internally, so tar must be present in the container. Supports copying in both directions.

PARAMETERS

-c, --container name

Container name in multi-container pod.
-n, --namespace name
Kubernetes namespace.
--no-preserve
Do not preserve file ownership and permissions.
--retries int
Number of retries on network errors (default: 0).

INSTALL

sudo apt install kubectl
copy
sudo pacman -S kubectl
copy
sudo apk add kubectl
copy
brew install kubectl
copy
nix profile install nixpkgs#kubectl
copy

CAVEATS

Requires tar to be installed in the container. If tar is missing, the copy will fail. Large file transfers may be slow as data is streamed through the API server. Symlinks in copied directories are not followed. The namespace/pod format uses `/` as separator (e.g., `mynamespace/mypod:/path`).

SEE ALSO

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