如何从特定命名空间中的容器中的容器复制文件? [英] How to copy file from container in a pod in a specific namespace?
本文介绍了如何从特定命名空间中的容器中的容器复制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说我有,我的名字空间->我的豆荚->我的容器 并且我在my-container中有一个文件:/opt/tomcat/logs/catalina.2017-05-02.log.我应用了以下命令来复制无法正常工作的文件,
Say I have, my-namespace -> my-pod -> my-container and I have a file located at my-container:/opt/tomcat/logs/catalina.2017-05-02.log. I have applied the below command to copy the file which isn't working,
kubectl cp my-namepace/my-pod:/opt/tomcat/logs/catalina.2017-05-02.log -c my-container .
注意:我的容器上有tar二进制文件
Note: I have the tar binary on my container
错误:
tar: Removing leading `/' from member names
error: open .: is a directory
推荐答案
这对我有用:
$(kubectl exec <pod-name> [-c <container-name>] -it -- cat <file-path>) > <local-file>
这篇关于如何从特定命名空间中的容器中的容器复制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文