Search code examples
dockercpuset

How to configure dockerd not to use some specific cpus?


all.

I want to reserve some cpus for realtime task. I tried to use cset utility,(https://github.com/lpechacek/cpuset/blob/master/doc/tutorial.txt) but failed since dockerd reserve all available cpu to its own cpuset.

Then, I reserved cpus 0~11 using cset shield --cpus 0-10 command before launching dockerd. But it didn't work either. cpus were shielded and dockerd was launched but couldn't start containers:

2021-07-19T17:11:13+09:00 myserver dockerd[59166]: time="2021-07-
19T17:11:13.267579743+09:00" level=error msg="fatal task error"
error="starting container failed: OCI runtime create failed:
container_linux.go:367: starting container process caused:
process_linux.go:340: applying cgroup configuration for process caused:
failed to write \"0-79\\n\": write /sys/fs/cgroup/cpuset/docker/cpuset.cpus:
invalid argument: unknown" module=node/agent/taskmanager 
node.id=rzeijp8jgedezsli9x4ftjugc service.id=z6cz3jtf6nz4293ye50l23f2o 
task.id=qn9zcc45rvjdk50jyaycri7lg

The cset result says cpuset gets conflict:

# cset set --list
cset: 
     Name       CPUs-X    MEMs-X Tasks Subs Path
 ------------ ---------- - ------- - ----- ---- ----------
     root       0-79 y     0-1 y   696    3 /
   docker      ***** n   ***** n     0    0 /docker
   system      12-79 y       0 n   481    0 /system
     user       0-11 y       0 n     0    0 /user

I guess that I need to tell dockerd not to use reserved cpus for its cpuset but cannot find how.

Any comments or suggestions will be appreciated deeply.


Solution

  • We can set dockerd configuration to /etc/docker/daemon.json. I set parent cgroup of docker to /system and the problem solved:

    # cat /etc/docker/daemon.json 
    {
      "cgroup-parent": "/system"
    }