Courseiva

XK0-006 Automation, Orchestration, and Scripting Practice Question

A Linux administrator is automating container lifecycle tasks with a script and needs to ensure a specific container, named webapp, is stopped cleanly and removed, while also removing its anonymous volumes. Which TWO docker commands should be used to accomplish this? (Choose two.)

⚠ Common exam trap

The trap here is reaching for docker kill or global volume pruning, which act forcefully or system-wide instead of cleanly targeting the named container and only its volumes.

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 rm -v webapp

A clean container teardown involves stopping the container so its main process receives SIGTERM and can exit gracefully, then removing the container with the -v flag to delete its anonymous volumes. Using SIGKILL or broad volume pruning bypasses graceful shutdown or affects unrelated resources, and removing an image does not address the container or its volumes.

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 volume prune -a

    Why it's wrong here

    This command removes all unused volumes system-wide, not just those attached to the webapp container. It is overly broad and would delete volumes belonging to other workloads, risking data loss. It also does not stop or remove the container, so it is not the appropriate paired action here.

  • ✗

    docker rmi webapp

    Why it's wrong here

    This command removes an image, not a container. Using it against a container name typically fails because no such image exists, and even if an image shared the name, it would not stop or remove the running container or its anonymous volumes, so it does not meet the scenario's needs.

  • ✓

    docker rm -v webapp

    Why this is correct

    Removing the stopped container with the -v flag also deletes any anonymous volumes associated with it, satisfying the requirement to clean up volumes. The container must be stopped first, which the other selected command handles, so this completes the lifecycle cleanup for the webapp container.

  • ✓

    docker stop webapp

    Why this is correct

    This command sends SIGTERM to the container's main process, waits a grace period, then sends SIGKILL if needed, allowing the application to shut down cleanly. Stopping the container before removal is the recommended practice to avoid abrupt termination and potential data corruption in the scenario's web application.

  • ✗

    docker kill webapp

    Why it's wrong here

    This command sends SIGKILL immediately, terminating the container without a graceful shutdown period. While it does stop the container, it does not allow the application to flush data or close connections cleanly, contradicting the requirement for a clean stop, and it does not remove volumes or the container itself.

About these practice questions

This XK0-006 question is part of Courseiva's 781-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 →

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.