Copy directories and files to and from Kubernetes Container [POD]

Nilesh Suryavanshi
Jul 25, 2017 · 1 min read

As we all know about SCP Linux command to Copy the files and directories from a remote host to the local host and vice versa over SSH.

Similar to that we have ‘KUBECTL CP’ to Copy the files and directories from a Kubernetes Container [POD] to the local host and vice versa.

Syntax:

kubectl cp <file-spec-src> <file-spec-dest>

POD in a specific container

kubectl cp <file-spec-src> <file-spec-dest> -c <specific-container>

Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace

kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar

Copy /tmp/foo from a remote pod to /tmp/bar locally

kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar

Nilesh Suryavanshi

@nilesh7756 | VMware NSX-T | Kubernetes | Openshift | PCF/PKS | Docker | AWS | GCE/GKE | DevOps

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade