2

I want to limit the cpu resources that are available to the docker containers on my system.I do not want to limit the resource consumption of individual containers but only for all containers combined.

First I have created a slice:

# /etc/systemd/system/limit-docker.slice
[Unit]
Description=Slice that limits docker resources
Before=slices.target

[Slice]
CPUAccounting=true
CPUQuota=300%

Then I configured the slice in /etc/docker/daemon.json

{
   "cgroup-parent": "/limit-docker.slice"
}

Then I reloaded systemctl and restarted docker

systemctl daemon-reload
systemctl restart docker

I then started a container and confirmed with systemd-cgls that the container is part of the control group

-.slice
├─limit-docker.slice
│ └─49d07f9319edfd727d4e6211d5d41c15daf49bc57174100d1ab80e2352170d7e
│   └─13685 python app.py execute 

However my specified resource limits are not respected

Control Group                                                       Tasks   %CPU   Memory   
/limit-docker.slice                                                    34  388.3     3.5G         
/limit-docker.slice/4…211d5d41c15daf49bc57174100d1ab80e2352170d7e      34  388.3     3.3G 

I see several warnings in the systemd logs regarding cgroups

level=warning msg="Your kernel does not support swap memory limit"
level=warning msg="Your kernel does not support cgroup rt period"
level=warning msg="Your kernel does not support cgroup rt runtime"

My understanding is that these cgroups are unrelated to what I want to achieve and it shouldn't matter that they are not supported. Is this correct?

Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.4.182-xenomai-2 
systemd: 232
Docker: 18.06.1-ce

Why are my resource restrictions ignored? What are my options troubleshooting this problem?

0

For anyone also struggling with this, instead of

systemctl daemon-reload
systemctl restart docker

do this

systemctl daemon-reload
systemctl start limit-docker.slice
systemctl restart docker
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.