mediumMultiple ChoiceObjective-mapped
XK0-006 Practice Question: A company runs a critical web application on a…
A company runs a critical web application on a single server using Docker containers. The application consists of a web frontend container and a backend API container. Recently, the server ran out of disk space due to Docker logs and temporary images. The sysadmin is tasked with automating cleanup to prevent recurrence. The solution must not disrupt running containers. Which approach should be taken?
⚠ Common exam trap
Candidates often choose Option C because `docker system prune -a -f` seems like a comprehensive cleanup, but they overlook that it can remove images needed by running containers (if they use intermediate layers) and does not address log growth, which is the primary cause of disk space exhaustion in this scenario.
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
✓
Configure log rotation for containers using `--log-opt max-size=10m` and `--log-opt max-file=3` in the Docker run command, and schedule `docker image prune -f` weekly.
It addresses both root causes: log growth and dangling images. Configuring `--log-opt max-size=10m` and `--log-opt max-file=3` limits container log file size and count without stopping containers, while `docker image prune -f` removes unused images safely. This combination prevents disk exhaustion without disrupting running containers, meeting all requirements.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Increase disk space by adding a new volume.
Why it's wrong here
This does not address the root cause of growing logs and images; the problem will recur.
- ✗
Create a script that stops all containers, removes unused images, and restarts containers.
Why it's wrong here
Stopping containers causes application downtime, which is not acceptable.
- ✗
Schedule a cron job to run `docker system prune -a -f` daily.
Why it's wrong here
This removes all unused images and volumes, potentially removing needed cached images, and does not limit log sizes.
- ✓
Configure log rotation for containers using `--log-opt max-size=10m` and `--log-opt max-file=3` in the Docker run command, and schedule `docker image prune -f` weekly.
Why this is correct
Log rotation keeps log files small, and pruning unused images safely removes them without affecting running containers.
Go deeper
Related to this question
About these practice questions
Courseiva writes every XK0-006 question from scratch — 979 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.