kubectl cp 命令报错 error: unexpected EOF

1、问题
使用kubectl cp命令将容器中的文件拷贝到本地时,抛出如下错误,无法完成拷贝

[root@harbor ~]# kubectl cp public-message-8486d4f975-whqrt:/tmp/error.hprof ./error.hprof -n hc-public
tar: removing leading '/' from member names
Dropping out copy after 0 retries
error: unexpected EOF

2、解决方法
添加–retries参数,指定重试次数,默认不重试,导致EOF错误。指定为-1表示一直重试

[root@harbor ~]# kubectl cp public-message-8486d4f975-whqrt:/tmp/error.hprof ./error.hprof -n hc-public --retries=-1
tar: removing leading '/' from member names
Resuming copy at 215351296 bytes, retry 1/-1
tar: removing leading '/' from member names

猜你喜欢

转载自blog.csdn.net/ljx1528/article/details/130625321