Which option with the kubectl logs command is used to fetch logs from a previously terminated container?

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 option with the kubectl logs command is used to fetch logs from a previously terminated container?

Explanation:
Pull the logs from a previously terminated container by using the previous flag. This tells kubectl to show the logs from the container instance that existed before the most recent restart, which is exactly what you need when a container has crashed and been recreated. If you’re targeting a specific container in a pod, add -c with the container name. For example: kubectl logs -p pod-name -c container-name. Following logs (-f) streams new output from the current running container, not the previous one. Limiting lines (--tail) affects how much of the current log you see, not which container instance’s logs you’re retrieving. The -l option isn’t used for selecting logs to fetch; label selection applies to choosing resources, not to the log stream itself.

Pull the logs from a previously terminated container by using the previous flag. This tells kubectl to show the logs from the container instance that existed before the most recent restart, which is exactly what you need when a container has crashed and been recreated. If you’re targeting a specific container in a pod, add -c with the container name. For example: kubectl logs -p pod-name -c container-name.

Following logs (-f) streams new output from the current running container, not the previous one. Limiting lines (--tail) affects how much of the current log you see, not which container instance’s logs you’re retrieving. The -l option isn’t used for selecting logs to fetch; label selection applies to choosing resources, not to the log stream itself.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy