Mounting cgroups for Resource Management in Docker Mounting cgroups for Resource Management in Docker docker docker

Mounting cgroups for Resource Management in Docker


After quite a bit of research, I figured this out, in-case anyone else out there has this same problem.

In reference to https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt, which is extremely helpful on understanding cgroups, a kernel with all of the proper support should have most of the cgroups for docker mounted by default. If not, there's a command to do so:

From section 2.1 - Basic Usage

"To mount a cgroup hierarchy with all available subsystems, type:

mount -t cgroup xxx /sys/fs/cgroup

The "xxx" is not interpreted by the cgroup code, but will appear in/proc/mounts so may be any useful identifying string that you like.

Note: Some subsystems do not work without some user input first. For instance,if cpusets are enabled the user will have to populate the cpus and mems filesfor each new cgroup created before that group can be used."

For this particular case, however, trying to mount an individual cgroup, such as cpuset, results in an error saying that the "cpuset special device does not exist". This is because the devs of Raspbian Jessie 8 didn't configure the kernel to support the cgroups that Docker uses for resource management by default. This can easily be determined by typing the docker info command, and seeing this at the bottom of the output:

WARNING: No swap limit supportWARNING: No cpu cfs quota supportWARNING: No cpu cfs period supportWARNING: No cpuset support

These are all of the cgroups that are needed for Docker to manage memory and CPU resources for containers. Testing to see if your kernel supports something like cpuset is easy. If the file /proc/filesystems has an entry that says nodev cpuset, then that means your kernel has cpuset support, but if you're reading this then it probably means it's just not configured in your kernel. That would call for a kernel reconfiguration and rebuild however, which is not so easy.

With the right kernel configurations, it just works automatically like it seems from the Docker Docs.