Which command would you use to view logs for a container named 'db' in a pod named 'backend' including previous logs?

Prepare for the KCNA Certification Test. Study with flashcards, multiple-choice questions, and detailed explanations to enhance your understanding of Kubernetes Cloud Native concepts. Ace your exam!

Multiple Choice

Which command would you use to view logs for a container named 'db' in a pod named 'backend' including previous logs?

Explanation:
To see logs from a specific container inside a pod and include logs from the previous container instance, you specify the pod, then indicate the container, and add the flag to show the previous logs. For a pod named backend with a container named db, the command kubectl logs backend -c db -p does exactly that: retrieves the db container’s logs and includes the previous run’s logs. The -c db selects the correct container when a pod has multiple containers, and the -p flag fetches logs from the previous instance (useful if the container restarted). Omitting -p would give only the current run’s logs, and not specifying the container with -c in a multi-container pod could lead to ambiguity.

To see logs from a specific container inside a pod and include logs from the previous container instance, you specify the pod, then indicate the container, and add the flag to show the previous logs. For a pod named backend with a container named db, the command kubectl logs backend -c db -p does exactly that: retrieves the db container’s logs and includes the previous run’s logs. The -c db selects the correct container when a pod has multiple containers, and the -p flag fetches logs from the previous instance (useful if the container restarted). Omitting -p would give only the current run’s logs, and not specifying the container with -c in a multi-container pod could lead to ambiguity.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy