Skip to content

How to find the pod details from container in OpenShift

Avatar photo

When we have issue with container and we are not sure which pod the container belongs to; we can find the pods details as below.

Use case : we have some zombie process running (defunct) but we are not sure which container is causing this zombie process.

Find the defunct processes

[root@node bin]# ps -ef |grep -v grep |grep -i defunct
1019710+  15222  15581  0 05:30 ?        00:00:00 [sh] 
1019710+ 15618 15581 0 05:30 ? 00:00:00 [sh] 1019710+ 37360 15581 0 Sep23 ? 00:00:00 [sh]
1019710+ 37569 15581 0 Sep23 ? 00:00:00 [sh] 1019710+ 37806 15581 0 Sep23 ? 00:00:00 [sh] 1019710+ 37939 15581 0 Sep23 ? 00:00:00 [git]

Find the docker image causing this zombies

We can use the systemd-cgls tool to find this; either run and search for the PID or grep for the PID.

[root@node bin]# systemd-cgls |grep -B4 15581
โ”‚   โ”‚   โ””โ”€95146 /usr/bin/pod
โ”‚   โ”œโ”€kubepods-burstable-poda3a903e7_b912_11e8_8c1f_40f2e91e547d.slice
โ”‚ โ”‚ โ”œโ”€docker-24695bc78b0f3908786fe00616df5sc023c9acc535aa4f53a8c5a04c96f840611.scope
โ”‚ โ”‚ โ”‚ โ”œโ”€15492 /usr/bin/dumb-init -- /usr/libexec/s2i/run
โ”‚ โ”‚ โ”‚ โ””โ”€15581 /usr/java/jdk1.8.0_181-amd64/bin/java -XX:+UseParallelGC -XX:โ€ฆ

You can see the info in docker line.

Find the container ID

(usually first 12 digit of that docker line)

[root@node bin]# docker ps |grep 24695bc78b0f
24695bc78b0f "/usr/bin/dumb-init -" 8 days ago Up 8 days k8s_jenkins-as-a-service-abcd_jenkins-as-a-service-abcd-18-qj76w_test_proj_a3a903e7-b912-11e8-8c1f-40f2e91e547d_0

We can read the project and pod information from above line by splitting last string by “_”.

  • jenkins-as-a-service-abcd – application
  • jenkins-as-a-service-abcd-18-qj76w – pod
  • test_proj – project
  • a3a903e7-b912-11e8-8c1f-40f2e91e547d – uid

Find and verify pod details from master

[root@master ~]# oc get pods|grep jenkins-as-a-service-abcd
and verify
[root@master ~]# oc get pod jenkins-as-a-service-abcd-18-qj76w -o=json

(Switch to respective project as you need)


The views expressed and the content shared in all published articles on this website are solely those of the respective authors, and they do not necessarily reflect the views of the author’s employer or the techbeatly platform. We strive to ensure the accuracy and validity of the content published on our website. However, we cannot guarantee the absolute correctness or completeness of the information provided. It is the responsibility of the readers and users of this website to verify the accuracy and appropriateness of any information or opinions expressed within the articles. If you come across any content that you believe to be incorrect or invalid, please contact us immediately so that we can address the issue promptly.

Avatar photo
Gineesh Madapparambath is the founder of techbeatly and he is the co-author of The Kubernetes Bible, Second Edition. and the author of ๐—”๐—ป๐˜€๐—ถ๐—ฏ๐—น๐—ฒ ๐—ณ๐—ผ๐—ฟ ๐—ฅ๐—ฒ๐—ฎ๐—น-๐—Ÿ๐—ถ๐—ณ๐—ฒ ๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป. He has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (aka Gini Gangadharan -


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.