Skip to main content

kubectl cp 复制文件

kubectl cp 复制文件

命令行里直接指明namespace、podname还有地址, 格式与scp差不多.

kubectl cp  localfile.jar  {namespace}/{pod-name}:/tmp

https://www.middlewareinventory.com/blog/kubectl-cp-example/

Kubectl CP is as simple as a typical Linux CP command.

kubectl cp <source-file-path> <destination-file-path>

Here is the syntax to copy a file from local to pod

kubectl cp /<path-to-your-file>/<file-name> <pod-name>:<fully-qualified-file-name> -c <container-name>

Here is the syntax to copy a file from the pod to local

kubectl cp <pod-name>:<fully-qualified-file-name> /<path-to-your-file>/<file-name> -c <container-name>

When you have multiple containers on the POD you need to specify the container to use with the copy operation using -c parameter

docker cp

docker复制文件, 可以使用docker cp命令, 参考下方例子将容器的文件复制到本地文件夹.

docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .