An example of cgroups and container:
We can use the "docker run" command to limit the cpu usage of a container using the cgroup subsystem cpu.shares in the cgroup file system "/sys/fs/cgroup/cpu" :
For a debian image, we use the "--cpu-shares" option to limits the "cpu time" a docker container gets:
The above command runs an interactive shell "-it" inside the "debian" image.
Inside the container:
We could verify the value of the "--cpu-shares" from inside the container:
Checking the "--cpu-shares" of the container from the host:
Linux created a subdirectory for docker and another one for the container as we can see from the alphanumerical container ID value.
Comments