OpenShift Documentation: Copying Files to or from a Container
Copying and Syncing Files
The oc cp and oc rsync commands work similar to their bash equivalents. Using them, it is possible to access / update files in a pod from the command line. E.g. The command
oc cp howdy-1-1234:/var/log/messages .
will copy log files from the howdy-1-1234 pod to the current directory on your local machine.
The following command will synchronize the contents of the remote /var/log/messages directory of the howdy-1-1234 pod with the current directory on your local machine:
oc rsync howdy-1-1234:/var/log/messages .
Both commands can also be used to copy files into the remote pod. The following command will synchronize the contents of the current directory on your local machine with the remote /var/log/messages directory of the howdy-1-1234 pod:
oc rsync . howdy-1-1234:/var/log/messages .
Note: A message that rsync is not available in the container may appear, but files can still be copied. This is a good option for examining current log or configuration files.
Working With Multi-Container Pods
Some pods will have multiple containers, such as having apache and tomcat instances as part of the same pod. In this case, you must specify the container which that files will be moved to or from. Here is an example:
oc rsync -c 'apache' mypod-1-53r40:/usr/local/apache2/local/certs .
Note: In this example the user is rsyncing files from the 'apache' container of a pod called 'mypod'. Similar syntax works for rsh'ing to that container.