How to solve unknown shorthand flag: 'R' error with CP command

4/16/2021

I am getting Error: unknown shorthand flag: 'R' in -R error when I run the line below. I'm aware of the root cause. It is -R. How can I run this command without issue?

kubectl -n $NAMESPACE -c vault cp -R /source /destination

P.S.: withour -R, I can run the command, but I want to copy the directories. Any help would be appreciated it. Thanks

-- cosmos-1905-14
bash
kubernetes
shell

1 Answer

4/16/2021

As Barmar said, this option doesn't exist on kubectl cp If you want to copy a directory into the container use the command below:

kubectl cp /home/local-dir <pod-name>:/tmp/container-dir

To copy the directory to a specific container into the pod use:

kubectl cp /home/local-dir <pod-name>:/tmp/container-dir -c container-name
-- Daniel Marques
Source: StackOverflow