How can you view logs for a specific container in a multi-container Pod?

Prepare for the Red Hat Openshift Developer EX288 Exam. Study with comprehensive quizzes and flashcards. Each question includes hints and explanations to enhance your understanding. Ace your exam with confidence!

Multiple Choice

How can you view logs for a specific container in a multi-container Pod?

Explanation:
To view logs for a specific container in a Pod that runs more than one container, you need to disambiguate which container’s logs you want. Use the logs command with the container flag to specify the container name: oc logs <pod-name> -c <container-name>. The -c option tells OpenShift which container inside the Pod to fetch logs from, which is essential when multiple containers are present. Without -c, the command may return logs for the default or only container, or fail, if several containers exist, so it won’t reliably target a single container. In OpenShift you use oc logs; kubectl logs can work in Kubernetes contexts, but there is no oc get logs command.

To view logs for a specific container in a Pod that runs more than one container, you need to disambiguate which container’s logs you want. Use the logs command with the container flag to specify the container name: oc logs -c . The -c option tells OpenShift which container inside the Pod to fetch logs from, which is essential when multiple containers are present. Without -c, the command may return logs for the default or only container, or fail, if several containers exist, so it won’t reliably target a single container. In OpenShift you use oc logs; kubectl logs can work in Kubernetes contexts, but there is no oc get logs command.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy