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

Prepare for the Kubernetes Cloud Native Associate (KCNA) Certification test with engaging questions and detailed explanations. Perfect your knowledge and boost your confidence to pass the exam successfully!

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