0
0
Dockerdevops~20 mins

Container resource usage stats in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Container Resource Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of the command to show live CPU and memory usage of a running container?
You run the command docker stats my_container --no-stream. What output will you see?
AA list of all containers with their IDs and names only, no resource usage details.
BAn error message saying 'container not found' because --no-stream is invalid.
CA table showing CPU %, memory usage, network IO, block IO, and PIDs for 'my_container' at the moment of running the command.
DA continuous live stream of resource usage stats until you stop it manually.
Attempts:
2 left
💡 Hint
The --no-stream option shows a snapshot, not a live stream.
🧠 Conceptual
intermediate
2:00remaining
Which Docker command option limits the CPU usage of a container?
You want to restrict a container to use only 50% of one CPU core. Which option do you use when running the container?
A--cpus 0.5
B--memory 512m
C--cpu-shares 1024
D--blkio-weight 500
Attempts:
2 left
💡 Hint
CPU shares are relative weights, not exact limits.
Troubleshoot
advanced
2:00remaining
Why does 'docker stats' show 0% CPU usage for a busy container?
You notice that 'docker stats' shows 0% CPU usage for a container that is actively processing tasks. What is the most likely reason?
AThe container is using CPU in a way that docker stats cannot measure, like GPU usage.
BThe container is running on a different CPU core not monitored by docker stats.
CThe container is paused, so no CPU is used.
DThe container is running with CPU limits set to zero, preventing CPU usage.
Attempts:
2 left
💡 Hint
Docker stats measures CPU usage of the container's CPU time, not GPU or other hardware.
🔀 Workflow
advanced
3:00remaining
Order the steps to monitor and limit memory usage of a Docker container
Arrange the following steps in the correct order to monitor and limit memory usage of a Docker container.
A2,1,3,4
B1,2,3,4
C1,3,2,4
D2,3,1,4
Attempts:
2 left
💡 Hint
You must set limits before monitoring and adjusting.
Best Practice
expert
3:00remaining
Which practice is best for ensuring accurate container resource usage monitoring in production?
You want to monitor CPU and memory usage of containers in production with minimal performance impact and accurate data. Which practice is best?
AManually SSH into each container and run top or free commands.
BRun 'docker stats' continuously on each host and parse output manually.
CRely on container logs to estimate resource usage periodically.
DUse a dedicated monitoring tool like cAdvisor or Prometheus with container metrics exporters.
Attempts:
2 left
💡 Hint
Automated tools designed for container monitoring provide better accuracy and less overhead.