

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Docker Logs
incomplete
2: Stats
incomplete
3: Top
incomplete
4: Resource Limits
incomplete
This lesson's interactive features are locked, please to keep using them
Okay, we know how to inspect a containers logs, but what if we want to see the resource utilization?
It's common to spin up some Docker containers, forget about them, and then wonder why your host machine has gotten really slow. It's really nice to see how much RAM/CPU each container is using, and it's critical in production environments.
The docker stats command gives you a live data stream of resource usage for running containers.
docker stats [OPTIONS] [CONTAINER...]
docker run -d --name cpu-stress alexeiled/stress-ng --cpu 2 --timeout 10m
This is going to slow down your machine somewhat while it's running, but don't worry we'll kill it soon. We added a timeout of 10 minutes just in case you forget to kill it later.
docker run -d --name mem-stress alexeiled/stress-ng --vm 1 --vm-bytes 1G --timeout 10m
This one will allocate a full gigabyte of memory for the container, which is a lot for a single container. Again, we'll kill it soon.
Run and submit the CLI tests.