A Linux administrator is trying to recover several gigabytes of disk space on a Docker host. She needs a single interactive command that will remove all stopped containers, any user-defined networks not attached to a container, dangling images, and build cache while retaining every named volume and any image that still has at least one tag-even if that image is not currently used by a container. Which Docker CLI command meets these requirements?
By default, the command docker system prune removes stopped containers, networks that are not used by at least one container, dangling images, and unused build cache. It does not delete named or anonymous volumes unless the --volumes flag is added, and it only deletes dangling (untagged) images-not tagged images, whether or not they are in use. Therefore it satisfies the stated constraints.
docker system prune -a would additionally delete every unused image, including tagged images that are not referenced by a container, which violates the requirement to keep tagged images.
docker system prune --volumes would also delete volumes, contradicting the need to retain them.
docker image prune -a removes only images and leaves stopped containers and unused networks behind, so it would not reclaim all the requested space. For these reasons, docker system prune is the only correct choice.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the `docker system prune` command do?
Open an interactive chat with Bash
What is a dangling image in Docker?
Open an interactive chat with Bash
Why does `docker system prune -a` delete tagged images?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .