Docker containers help make software deployment faster and more efficient.
In order to ensure that you’re getting as much efficiency out of Docker as you can, however, you need to track Docker performance metrics. Monitoring Docker container performance is also important for troubleshooting problems.
The tricky thing about Docker, however, is that it doesn’t log information to a central location. Unlike most other Linux apps, Docker doesn’t dump log data into a file in /var/log that you can access conveniently when you want to get information about application performance or problems.
This doesn’t mean that you can’t measure Docker performance. You can. You just have to know where to look—specifically, in particular directories. In this post, I’ll explain where to find Docker performance information and what to look for to help maximize Docker performance.
Accessing Docker Container Performance Metrics
Information about running Docker containers themselves—how much CPU, memory and so on they are consuming—is spread across a variety of small files (technically, these are pseudo-files, not actual files) that live deep inside your Docker host server’s /sys directory.
There are three main subdirectories of interest when you’re tracing Docker performance. Each corresponds to a different type of data: CPU usage, memory usage and disk I/O.
Docker writes information about CPU usage inside this directory:
Each of the files in this directory contains real-time information related to CPU metrics. For details, check out the Docker documentation.
You can also view CPU information on a per-container basis by opening the subdirectory for the container whose information you want to view. The names of subdirectories map to your container IDs.
The most useful file in this directory is cpuacct.stat, which tells you the total CPU time accumulated by your container processes.
You can find data about memory consumption in:
This directory works in the same way as the one described above that contains information about CPU usage.
The most interesting file is memory.stat. (Again, refer to the Docker documentation for details on interpreting the information within this file.)
Last but not least is I/O data for your containers. You can find these metrics inside this directory:
You’ll see many files in this directory, and on most types of host systems you’ll find most of the files to be empty. The one worth paying attention to, however, is:
This file tells you the total I/O bytes consumed by your containers.
Measuring Docker performance by accessing the files described above can help you to track the overall health of your Docker environment and make sure your containers are running as efficiently as possible.
Reading these files manually is not a practical Docker monitoring solution in a large-scale environment, of course. For that, you’d want an APM tool that can collect Docker performance metrics automatically and help you interpret them.
Still, knowing where to find Docker performance information is important for troubleshooting performance problems with specific containers, as well as for understanding how your system resources are being allocated across your environment.