Check RAM & CPU usage of containers

If your server host is experiencing high RAM and/or CPU usage, despite adhering to the tech specs, you can check via the command line which container is consuming the available host RAM/CPU.

To do this, establish a connection to your host and run the following command (as sudo):

sudo docker stats

All containers share the resources available within the Docker environment, except for those that haven't been restricted via resource constraints (optional, not by default).

For example, CPU usage can range from 0% to 800% for an 8-core CPU, or 900% for a 9-core CPU, and so forth.

RAM usage is displayed in the MEM USAGE column, while the maximum amount of RAM (for all containers) is visible in the LIMIT column.

It's important to note that the LIMIT is the same for all containers, so you need to tally up the values from the MEM USAGE column to determine the current actively used RAM.

If a container is consuming a significantly high amount of RAM, for example, if IO is using 9GB, it should be restarted to free up memory.

Please perform this action only when there are no active jobs being executed and avoid doing so during high production time slots, if possible.

Last updated