XK0-006 Automation, Orchestration, and Scripting Practice Question
A containerized application uses a volume to persist data. The administrator needs to create a new volume named 'data-vol' and mount it to /app/data in the container. Which of the following commands accomplish this? (Select all that apply.)
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
✓
docker run --mount type=volume,source=data-vol,target=/app/data myapp
Both options A and C are correct because they create the volume automatically if it doesn't exist and mount it to the container. The `--mount` flag (option A) uses a more explicit syntax compared to the `-v` flag (option C), but both achieve the same result. Option B is incorrect because the leading slash in `/data-vol` causes a bind mount from the host, not a named volume. Option D is incorrect because it uses two separate commands (`docker volume create` and `docker run`), while the question asks for a single command that both creates and mounts the volume.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
docker run --mount type=volume,source=data-vol,target=/app/data myapp
Why this is correct
Correct. The `--mount` flag with `type=volume` automatically creates the volume if it does not exist and mounts it to the container.
- ✗
docker run -v /data-vol:/app/data myapp
Why it's wrong here
Incorrect. The leading slash in `/data-vol` specifies a bind mount from the host, not a named volume, so it does not create a Docker volume.
- ✓
docker run -v data-vol:/app/data myapp
Why this is correct
Correct. The `-v` flag with a volume name (no leading slash) automatically creates the volume if it does not exist and mounts it to the container.
- ✗
docker volume create data-vol && docker run -v data-vol:/app/data myapp
Why it's wrong here
Incorrect. This uses two separate commands (`docker volume create` and `docker run`), not a single command as implied by the question.
Go deeper
Related to this question
About these practice questions
One of 979 original XK0-006 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.