Copying Container Files
Copying Container Files
TL;DR
- Copy files to and from Containers in a cluster
Copying Container Files
Motivation
- Copying files from Containers in a cluster to a local filesystem
- Copying files from a local filesystem to Containers in a cluster
Install Tar
Copy requires that tar be installed in the container image.
Local to Remote
Copy a local file to a remote Pod in a cluster.
- Local file format is
<path>
- Remote file format is
<pod-name>:<path>
kubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir
Remote to Local
Copy a remote file from a Pod to a local file.
- Local file format is
<path>
- Remote file format is
<pod-name>:<path>
kubectl cp <some-pod>:/tmp/foo /tmp/bar
Operations
One can also perfrom operations such as:
- Copy a specific container within a Pod running multiple containers
- Set the Pod namespace by prefixing the Pod name with
<namespace>/
.
Command / Examples
Check out the reference for commands and examples of cp
当前内容版权归 kubernetes官网 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 kubernetes官网 .