Forrest logo
back to the docker tool

docker:tldr:02cc7

docker: Change the columns format to display container's CPU usage percentage.
$ docker stats --format "${-Name}:\t${-CPUPerc}"
try on your machine

The command docker stats --format "${-Name}:\t${-CPUPerc}" is used to display container-level performance statistics using Docker.

Here's a breakdown of the command:

  • docker stats: This is the main command to display real-time container statistics such as CPU, memory, and network usage.
  • --format: This flag specifies the format of the output. It allows you to define a format string to customize the displayed information.
  • "${-Name}:\t${-CPUPerc}": This is the format string used to define the output format. In this case, it consists of two placeholders: ${-Name} and ${-CPUPerc} which represent the container name and the CPU percentage usage respectively. The '\t' is an escape sequence for a tab character, used to separate the container name and CPU percentage in the output.

So, when you run the command docker stats --format "${-Name}:\t${-CPUPerc}", you will see a continuously updating stream of container names followed by a colon (:) and the corresponding CPU percentage usage, separated by a tab character.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the docker tool