Bootstrap FreeKB - OpenShift - Copy file between container and host using the oc cp command
OpenShift - Copy file between container and host using the oc cp command

Updated:   |  OpenShift articles

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

The oc cp command can be used to copy a file in a pod to a directory on the host operating system, or to copy a file on the host operating system to a directory in a pod.


Copy a single file from pod to host

In this example, the /usr/local/foo.txt file in the pod is copied to /tmp on the host operating system (the OpenShift system).

oc cp my-pod-kjr9m:/usr/local/foo.txt /tmp

 


Copy a directory from container to host

In this example, every file and directory below /usr/local in my-pod-kjr9m will be copied to /tmp on the host operating system (the OpenShift system).

oc cp my-pod-kjr9m:/usr/local /tmp

 

Or, the oc rsync command can be used.

oc rsync my-pod-kjr9m:/usr/local /tmp

 


Copy from host to container

In this example, the /tmp/foo.txt file on the host operating system (the OpenShift system) is copied to /usr/local in my-pod-kjr9m.

oc cp /tmp/foo.txt my-pod-kjr9m:/usr/local

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter da9b30 in the box below so that we can be sure you are a human.