Bartosz Bierkowski - Low dose cloud

OpenShift Morsels: oc exec – exploring the pod

Quick look at the oc exec on Day #8.

As an alternative to oc rsh , you can use oc exec for single command that should be executed inside the pod. The command will execute something in the pod and return you the result. That is often good enough to list some file content or retrieve list of files in the directory.

Since the pod is involved, you can select specific container using -c <container>  parameter.

Interesting option is using -i  to pass the standard output to the container. To learn the difference between using and omitting it, you can execute base64 -d  in your pod to decode the base64 encoded text DQpIZWxsbyB3b3JsZA0K

The Ctrl-D  will be passed to the pod and the command will successfully decode the text.

Now test the same behaviour without passing it  -i  parameter.


oc exec -h – always check it and read the description for useful hints – official OpenShift Origin documentation


The commands were executed using minishift and the following client/server versions of OpenShift.

oc v3.6.1+008f2d5
client kubernetes v1.6.1+5115d708d7
openshift v3.6.0+c4dd4cf
server kubernetes v1.6.1+5115d708d7


Thanks for reading the OpenShift morsels. To get updates about new articles, you can sign up to the newsletter below.

As a thank you message, you will also get access to OpenShift CLI CheatSheet listing most commonly used commands together with a short explanation.

Did you like the article?
Join the newsletter to receive notifications about new articles.
I respect your privacy.