Courseiva

XK0-006 Automation, Orchestration, and Scripting Practice Question

A Docker container needs persistent storage that survives container restarts. Which of the following is the recommended method to achieve this?

⚠ Common exam trap

The trap is thinking that a restart policy or storing data in the container layer provides persistence; candidates must recognize that only volumes (or bind mounts) decouple data from the container lifecycle, and volumes are the recommended default.

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 Docker volume

Docker volumes are the recommended mechanism for persistent data because they are managed by Docker, stored outside the container's writable layer (typically under /var/lib/docker/volumes), and survive container removal and restarts. They can be named, shared between containers, and backed up or migrated independently of the container lifecycle. This directly satisfies the requirement for storage that persists across restarts.

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 Docker volume

    Why this is correct

    Docker volumes store data outside the container's writable layer, in a host-managed directory, so it persists independently of the container lifecycle. This directly satisfies the requirement that storage survives restarts, unlike bind mounts tied to host paths or data written inside the container, which is destroyed on removal.

  • ✗

    Store data inside the container filesystem

    Why it's wrong here

    A container's writable layer is destroyed when the container is removed or recreated, so data written there does not survive restarts. Docker volumes exist precisely to persist data outside the container lifecycle. Storing data in the image filesystem suits only disposable, stateless workloads where no data must outlive the container.

  • ✗

    Use a bind mount only for configuration files

    Why it's wrong here

    Bind mounts can persist data, but restricting them to configuration files leaves application data inside the container's ephemeral layer, which is lost on recreation. Docker volumes are the recommended mechanism for persistent application data. Bind mounts suit injecting host configuration files, not storing stateful data.

  • ✗

    Set the container to always restart

    Why it's wrong here

    A restart policy only controls whether Docker relaunches a stopped container; it does not preserve the writable layer, which is recreated from the image. Volumes persist data independently of container lifecycle. Restart policies suit keeping long-running services available, not retaining state across container replacement.

About these practice questions

One of 781 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 →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

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.