mediumMultiple ChoiceObjective-mapped
XK0-006 Docker volumes Practice Question
A container is running a database service that requires persistent storage. The administrator wants to ensure that data persists even if the container is removed. Which volume mount type should be used in the Docker run command?
⚠ Common exam trap
The trap is that candidates might think bind mounts are the only way to achieve persistence, but Docker volumes also persist data and are actually the recommended approach for persistent storage. The key is that volumes are managed by Docker and are more portable.
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
✓
--mount type=volume
Docker volumes are the preferred mechanism for persisting data generated by and used by Docker containers. Volumes are completely managed by Docker, are independent of the container lifecycle, and can be backed up easily. They persist even after the container is removed, making them ideal for database services. While bind mounts (option B) also provide persistence by mapping a host directory, they are less portable and have security considerations. Since the question does not specify a need for host directory mapping, volumes are the recommended choice.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
--mount type=volume
Why this is correct
Volumes are the recommended way to persist data in Docker. They are managed by Docker and survive container removal.
- ✗
--mount type=bind
Why it's wrong here
Bind mounts also persist data, but they are less flexible and not the recommended default for database persistence. Docker volumes are preferred.
- ✗
COPY in Dockerfile
Why it's wrong here
COPY is a Dockerfile instruction to copy files into an image, not a runtime mount for persistence.
- ✗
--mount type=tmpfs
Why it's wrong here
tmpfs mounts are temporary and stored in memory, so data is lost when container stops.
Go deeper
Related to this question
Learn chapter
System Services and Startup
Key term
Service
A service is a software component or system that performs a specific function and is available to be used by other programs or users over a network.
Key term
Mount
Mounting is the process of making a file system or storage device accessible to a computer's operating system by attaching it to a specific directory in the existing directory tree.
About these practice questions
This XK0-006 question is part of Courseiva's 979-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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 XK0-006 practice question is part of Courseiva's free CompTIA 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 XK0-006 exam.