0

I'm using Ubuntu 21.10 and would like to restrict the system resources (CPU, MEM) for a subset of my docker containers - not for a particular container. How can I do that?

user2809176
  • 1,042
  • 12
  • 29

1 Answers1

0

I figured out some solution. There is a docker param to us on a container start.

First you need to create mygroup.slice in /etc/systemd/system/mygroup.slice and run systemctl daemon-reload.

[Unit]
Description=my cgroup for Docker
Before=slices.target

[Slice]
MemoryAccounting=true
MemoryHigh=7G
MemoryMax=7.5G
CPUAccounting=true
CPUQuota=50%

After that one can start a set of containers with the next argument.

--cgroup-parent=mygroup.slice

An finally run systemd-cgtop to check the resource allocation.

user2809176
  • 1,042
  • 12
  • 29