Home > Back-end >  'kubectl cp' command doesn't copy the target directory but its contents
'kubectl cp' command doesn't copy the target directory but its contents

Time:11-30

 kubectl cp namespace/podname:/path/target .

If I use the instructed command from kubernetes guide, it only copies the contents inside the target directory and omits target itself.
I don't want to use mkdir every time I need to copy.
What's the option?

CodePudding user response:

Try kubectl cp namespace/podname:/path/target target. Note specify "./target" will receive a warning: "tar: removing leading '/' from member names". Also, ensure your image have tar command or kubectl cp can fail.

  • Related