HiveBrain v1.2.0
Get Started
← Back to all entries
snippetkubernetesMajor

How to copy files recursively to a Kubernetes pod?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
kubernetesrecursivelyfileshowpodcopy

Problem

I want to copy files recursively to a Kubernetes pod

I tried kubectl cp -r

I got:
error: unknown shorthand flag: 'r' in -r

What are the best ways to transfer whole directories recursively into a pod.

Solution

kubectl cp by default does recursive copies when given a directory, although it seems to be picky about trailing slashes. If foo/bar is the directory you'd like to copy, simply run

kubectl cp /path/to/foo/bar :/path/in/container/foo/

Code Snippets

kubectl cp /path/to/foo/bar <pod-id>:/path/in/container/foo/

Context

StackExchange DevOps Q#3127, answer score: 35

Revisions (0)

No revisions yet.