How to get quick stats on your Docker containers

If you're looking for an easy way to check the health of your containers, Jack Wallen introduces you to the stats option for the docker command.

Image: Jack Wallen

You have Docker up and running, and you've deployed numerous containers onto your network. It should be safe to assume those containers are doing well. But, as we all know, when you assume...

That is especially true within the realm of IT. You never want to assume everything is going okay. To that end, what can you do to monitor your Docker containers? Fortunately, the Docker developers have thought that through, and included a very easy-to-use monitoring tool that gives you insight into how your containers are running.

I want to show you how to make use of that feature.


The tool in question is really just an option used with the docker command, and displays a real-time stream of information pertaining to your containers. Log into your Docker server and issue the command (as a user who has permission to run docker):

docker stats

You will be presented with the stats of your currently running containers (Figure A).

Figure A

Figure A

The stats of my currently running containers.

The default command will display the container ID; CPU, Memory, NET, and BLOCK usage; and the Process ID of the container. If you don't need all of that information, you can format the command to display only what you want. Say, for instance, you only want to see the Container ID and CPU/MEM/NET usage. Using the —format option like so, will display only that information:

docker stats --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}"

The resulting information would look like that shown in Figure B.

Figure B

Figure B

A formatted docker stats output.

The various formatting placeholders are:

  • .Container — displays the container ID
  • .Name — displays the container name
  • .ID — displays the container ID
  • .CPUPerc — displays the CPU percentage
  • .MemUsage — displays the memory usage
  • .NetIO — displays the network I/O
  • .BlockIO — displays the Block I/O
  • .MemPerc — displays the memory percentage
  • .PIDs — displays the number of process IDs

You can also format your output in an even more simplistic manner, like so:

docker stats --format "{{.Container}}: {{.CPUPerc}}"

The above command would only display the Container ID followed by the CPU percentage (Figure C).

Figure C

Figure C

A very simplistic format for docker stats.

And that's it for using docker stats. It's a very simple tool that gives you a quick insight into how your containers are doing. Should you find your Docker server misbehaving, issue the docker stats command to see if one of your running containers is the culprit. Should you find a container taking up too much in the way of system resources, you could restart that container and recheck the stats. Easy container administration.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website

Editor's Picks

Free Newsletters, In your Inbox