Bartosz Bierkowski - Low dose cloud

OpenShift Morsels: Troubleshooting pods with oc debug

Day #1 lets talk about troubleshooting pods. Since several versions of OpenShift Client you can use a very simple and powerful command to check what is wrong with your application.

Normally when a pod starts, docker executes whatever we put in the CMD  or ENTRYPOINT  directive. In case the command fails for whatever reason, it is already too late in the process to check what went wrong. You are lucky if you have some logs explaining what happened. If not, the only thing you can do is start adding them or attach to a container running bash and trying to manually launch the command from the above directives.

Here is where the oc debug <pod> is helpful. It creates a new layer with bash as entrypoint. After running it you are immediately logged in into the pod and some useful information is printed out at start – like the original command executed in the pod.

This way you can just try to run it manually from shell without pod being restarted due to failure.

Inside the pod you run as the same user your original pod would. This helps solving any filesystem permission problems.

The directory is also the same WORKDIR  as specified in the Dockerfile.

In case of trouble, one of the first steps can be getting into the pod and looking for yourself what happens when the application starts.


Learn more about command line options by running oc debug --help


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.