LinuxCommandLibrary

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

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 permissions.

CAVEATS

Requires tar to be installed in the container. Large file transfers may be slow as data is streamed through the API server.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community