0
0
Dockerdevops~20 mins

Resource monitoring per container in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Resource Monitoring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Check CPU usage of a running container
You want to see the current CPU usage of a container named webapp. Which command will show this information?
Adocker stats webapp --no-stream
Bdocker inspect webapp --format '{{.State.CpuUsage}}'
Cdocker top webapp
Ddocker logs webapp --cpu
Attempts:
2 left
💡 Hint
Use a command that shows live resource usage statistics for containers.
💻 Command Output
intermediate
1:30remaining
Memory usage output format
You run docker stats --no-stream and see the memory usage column showing 50MiB / 500MiB. What does this mean?
AThe container is using 500 MiB and has 50 MiB available
BThe container has 50 MiB free and 500 MiB used
CThe container is using 50 MiB of memory out of a 500 MiB limit
DThe container has 50 MiB total memory and 500 MiB swap
Attempts:
2 left
💡 Hint
The format is usually 'used / limit'.
Configuration
advanced
2:30remaining
Limit CPU usage of a container
You want to limit a container named db to use at most 0.5 CPU cores. Which command correctly starts the container with this limit?
Adocker run --cpu-shares=0.5 --name db mydbimage
Bdocker run --cpus=0.5 --name db mydbimage
Cdocker run --cpu-quota=50000 --name db mydbimage
Ddocker run --cpulimit=0.5 --name db mydbimage
Attempts:
2 left
💡 Hint
Use the flag that sets the number of CPUs directly.
Troubleshoot
advanced
3:00remaining
Diagnose why container memory usage is high
A container api is using more memory than expected. You want to check its memory limit and usage. Which sequence of commands helps you find this info?
Adocker stats api --no-stream; docker inspect api --format '{{.HostConfig.Memory}}'
Bdocker exec api free -m; docker inspect api --format '{{.State.MemoryUsage}}'
Cdocker logs api; docker top api
Ddocker stats api; docker inspect api --format '{{.Config.Memory}}'
Attempts:
2 left
💡 Hint
One command shows current usage, the other shows configured limits.
Best Practice
expert
3:00remaining
Efficient resource monitoring setup for multiple containers
You manage many containers and want to monitor CPU and memory usage continuously with minimal overhead. Which approach is best?
AUse 'docker stats' with --no-stream repeatedly in a script every second
BCheck container logs for resource usage messages periodically
CRun 'docker top' on each container every minute and parse output
DInstall a monitoring agent like cAdvisor or Prometheus node exporter on the host
Attempts:
2 left
💡 Hint
Look for a scalable and low-overhead monitoring solution.