Which kubectl command is used to view the logs of a terminated container in a multi-container pod?

Study for the Kubernetes Certified Network Administrator Exam. Our test offers comprehensive flashcards, multiple-choice questions, and detailed explanations. Be confident for your exam!

Multiple Choice

Which kubectl command is used to view the logs of a terminated container in a multi-container pod?

Explanation:
To see what happened in a container that has terminated, you need the logs from its previous instance. The -c flag selects the specific container inside a pod that has multiple containers, and the -p flag is the shorthand for --previous, which asks kubectl to show the logs from the previously terminated container instance rather than the current one. This combination is the direct way to retrieve those terminated-container logs. Without the -p flag, you’d typically get the logs from the running (or last active) instance, which isn’t what you want when the container has ended. The other forms either target the current run or mix flags in ways that don’t clearly fetch the previous logs for the chosen container.

To see what happened in a container that has terminated, you need the logs from its previous instance. The -c flag selects the specific container inside a pod that has multiple containers, and the -p flag is the shorthand for --previous, which asks kubectl to show the logs from the previously terminated container instance rather than the current one. This combination is the direct way to retrieve those terminated-container logs. Without the -p flag, you’d typically get the logs from the running (or last active) instance, which isn’t what you want when the container has ended. The other forms either target the current run or mix flags in ways that don’t clearly fetch the previous logs for the chosen container.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy