Day 7: Copy content from-to container using kubectl

Below are the commands to copy file from and to containers using kubectl commands. Remember even if you are using windows containers you will still need the linux paths to make it work.

Copy FROM CONTAINER to LOCAL and the format of the command is

kubectl cp NAMESPACE/PODNAME:/tmp/foo.txt ./foo.txt

kubectl cp i-install/i-install-7445ffb8df-jshk9:sites/web/web.config ./temp.txt

Copy FROM LOCAL to CONTAINER and the format of the command is

kubectl cp /tmp/foo.txt NAMESPACE/PODNAME:/tmp/foo.txt

kubectl cp ./temp.txt i-install/i-install-7445ffb8df-jshk9:sites/web/web.config

Leave a Reply

Your email address will not be published. Required fields are marked *