Check cgroup Version Used by Docker

Check cgroup Version Used by Docker

Linux control groups, commonly known as cgroups, provide mechanisms for controlling and monitoring resources allocated to processes and containers. Docker relies on cgroups to apply limits and manage resources such as CPU, memory, and other system resources. This tutorial demonstrates how to check cgroup version used by Docker.

Different Linux systems may use different cgroup versions. The two commonly encountered versions are cgroup v1 and cgroup v2. Docker provides the cgroup information through the docker info command. The output contains a Cgroup Version field that indicates which version is being used by the Docker environment. Instead of displaying the complete Docker information, sed command can be used to extract only particular value.

Run the following command:

docker info | sed -n 's/ *Cgroup Version: *//p'

The command first executes docker info, which provides information about the Docker installation and runtime environment. The output is then passed to sed command, which searches for the Cgroup Version entry and removes the field name, leaving only the version number.

For a Docker environment configured to use cgroup v2, the result is 2.

Leave a Comment

Cancel reply

Your email address will not be published.