CKAD Application Design and Build Practice Question
A pod has two containers: a web server and a sidecar that scrapes logs. The sidecar container needs to read log files written by the web server. How should the logs be shared between the containers?
⚠ Common exam trap
A common misconception is that hostPath is the default or simplest way to share files between containers, but the correct Kubernetes-native pattern for ephemeral, intra-Pod log sharing is an emptyDir volume, which is portable and automatically lifecycle-managed.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use a shared emptyDir volume mounted into both containers at the same path
An emptyDir volume is a shared, ephemeral volume that is created when a Pod is assigned to a node and exists as long as that Pod is running. Both containers in the same Pod can mount the same emptyDir volume at the same or different paths, allowing the sidecar to read log files written by the web server without any external storage dependency. This is the standard Kubernetes pattern for inter-container log sharing within a Pod.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use a ConfigMap to store logs
Why it's wrong here
ConfigMaps hold configuration data as key-value pairs, are read-only when mounted, and are not designed for continuously written log files. The sidecar needs a writable shared filesystem, which an emptyDir volume mounted in both containers provides for the pod's lifetime.
- ✗
Use a hostPath volume mounted in both containers
Why it's wrong here
hostPath binds the mount to a specific node's filesystem, so the sidecar reads logs only when both containers land on that node and the path exists there; it also leaks data across pods. An emptyDir volume scoped to the pod is the intended mechanism for sharing files between containers in the same pod.
- ✓
Use a shared emptyDir volume mounted into both containers at the same path
Why this is correct
An emptyDir volume is created when the pod starts and exists for the pod's lifetime, and mounting it into both containers at the same path gives the sidecar direct filesystem access to the log files the web server writes, satisfying the sharing requirement.
- ✗
Use a PersistentVolumeClaim
Why it's wrong here
A PersistentVolumeClaim provides storage that outlives the pod and is intended for durable data, not intra-pod file sharing between containers. It also requires a StorageClass and binding, adding needless lifecycle overhead. The correct mechanism is an emptyDir volume mounted at the same path in both containers, which shares the pod's ephemeral lifetime.
Go deeper
Related to this question
About these practice questions
Courseiva writes every CKAD question from scratch — 826 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKAD practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKAD exam.