Bartosz Bierkowski - Low dose cloud

OpenShift Morsels: oc rsh – exploring the pod

On Day #7 lets see how to explore the contents of the container. How does ssh work in the containerized world?

When working with linux hosts, you can explore them by using ssh. Connect to the remote IP or host  and work as if you were doing it locally – modulo restrictions, latency, missing tools.


On the container level, OpenShift client provides the oc rsh command to allow you to get a shell session in the pod.

By default the /bin/sh  is used for shell command. You can use

oc rsh <pod> --shell=/bin/bash  – will create a bash shell if you have it installed in the container. Otherwise it fails.

oc rsh <pod> -c <container>  – as usual when the pod interaction is in scope, you can specify the container that should be used for the connection.

OpenShift Console

It is also possible to get the shell directly from the WebUI. After selecting one of the pods, you have access to Terminal tab. This is what you are looking for if you want to quickly execute some commands in the pod.


oc rsh --help – as always worth checking for hidden gems. – some official documentation for the command


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.