OpenShift - List the containers in a deployment or pod

by
Jeremy Canfield |
Updated: January 19 2023
| OpenShift articles
If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.
The oc describe command can be used to list the containers in a deployment or a pod. In this example, the deployment named "php" contains one container named "php-74"
~]$ oc describe deployment php-74
Name: php-74
Namespace: foo
Pod Template:
Containers:
php-74:
Image: registry.redhat.io/ubi8/php-74@sha256:9b0179ab95c05af2ad8836a6fc6078da92833c63610c1dfe9f0fb51519e9b545
Ports: 8443/TCP, 8080/TCP
Host Ports: 0/TCP, 0/TCP
Environment: <none>
Mounts: <none>
Likewise, in this example, the pod named php-74-64c9588895-qgxjc contains one container named "php-74".
~]$ oc describe pod php-74-64c9588895-qgxjc
Name: php-74-64c9588895-qgxjc
Namespace: foo
Containers:
php-74:
Image: registry.redhat.io/ubi8/php-74@sha256:9b0179ab95c05af2ad8836a6fc6078da92833c63610c1dfe9f0fb51519e9b545
Ports: 8443/TCP, 8080/TCP
Host Ports: 0/TCP, 0/TCP
Environment: <none>
Mounts: <none>
Or, the oc get command with the --output jsonpath option can be used to return the name of the containers in a deployment or a pod.
~]$ oc get pod my-app-wzvjr --output jsonpath={.spec.containers[*].name}
my-foo-container my-bar-container
Did you find this article helpful?
If so, consider buying me a coffee over at