How Can You Change the cgroups Settings for Docker Containers while Bypassing Docker?

Problem scenario
You want to bypass Docker and configure the cgroups directly. You want new Docker containers to be governed by these customized settings. What should you do?

You may not want to bypass Docker for your cgroup modifications. You should read about the libcontainers. By default Docker uses libcontainers for granular configuration changes along the lines of modifying cgroups settings. You could potentially use LXC, but libcontainers are standard for Docker now.

You may want to look into the docker create command with the cgroup-parent option.

At a minimum with older versions of Docker (before 1.6 per page 161 of Docker Up and Running by Matthias & Kane), you should not try to modify cgroups directly for the benefit of having future Docker containers be governed by such settings. We base this assertion on the following quotes from a book published in June of 2015:

"Changing cgroups values yourself, outside of any Docker configuration, breaks some of the repeatability of Docker deployment. Unless you tool changes into your deployment process, settings will go away when containers are replaced." page 159 of Docker Up and Running by Matthias & Kane

"You can't set cgroups for things that aren't running because they apply to running processes." page 160 of Docker Up and Running by Matthias & Kane

Leave a comment

Your email address will not be published. Required fields are marked *