We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Stats

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...]

Assignment

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.