You open an SSH session to a production Linux host that runs Docker Engine 24×7. A recent docker system df report shows many stopped containers, dangling image layers, and several anonymous volumes taking up 30 GB of space. Management wants you to reclaim every byte not tied to a running container, including unused volumes, in a single, fully non-interactive step that can be placed in a weekly cron job. Which command achieves this goal?
The most comprehensive one-liner is docker system prune -a --volumes --force. The system prune sub-command removes stopped containers, unused networks, dangling build cache, and images. Adding -a expands image removal to all images not referenced by any container, --volumes prunes anonymous volumes that no container is using, and --force (or -f) bypasses the confirmation prompt-making the command suitable for unattended execution.
docker image prune -a --force touches only images; containers, networks, and volumes remain. docker container prune --force deletes stopped containers but leaves images, networks, caches, and volumes. docker volume prune --force affects volumes alone and would leave the bulk of the unused space untouched. Therefore, only the system-wide prune with the extra flags meets every stated requirement.
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 the purpose of the `-a` and `--volumes` flags when used with `docker system prune`?
Open an interactive chat with Bash
How does `docker system prune` compare to other prune commands like `docker image prune` or `docker volume prune`?
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...
IT & Cybersecurity Package Join Premium for Full Access