admin管理员组

文章数量:1389861

My codebase is using docker cli client (.go#L17) to run docker container with cpu-period and cpu-quota. The container starts with the correct cpu-quota. I can verify the same using below command:

docker exec <container-name> cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us

But when I see the below path on the host (i.e. the VM), I see wrong value for quota (i.e. -1 which means no quota set). sudo cat /sys/fs/cgroup/cpu/<container-name>/cpu.cfs_quota_us

There is a stats collector program in my VM which collects stats for cgroups from this path on the VM. So it's collecting wrong stats for cgroup corresponding to the docker container.

Can you suggest why the path on host doesn't show the correct cpu quota value?

Platform:

Rocky linux 8
Docker version 24.0.9
Using cgroups-v1

Edit 1: The path /sys/fs/cgroup/cpu/docker doesn't exist for me. I have paths /sys/fs/cgroup/cpu// for each docker container.

My codebase is using docker cli client (https://github/moby/moby/blob/9674540ccff358c3cd84cc2f33c3503e0dab7fb7/daemon/start.go#L17) to run docker container with cpu-period and cpu-quota. The container starts with the correct cpu-quota. I can verify the same using below command:

docker exec <container-name> cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us

But when I see the below path on the host (i.e. the VM), I see wrong value for quota (i.e. -1 which means no quota set). sudo cat /sys/fs/cgroup/cpu/<container-name>/cpu.cfs_quota_us

There is a stats collector program in my VM which collects stats for cgroups from this path on the VM. So it's collecting wrong stats for cgroup corresponding to the docker container.

Can you suggest why the path on host doesn't show the correct cpu quota value?

Platform:

Rocky linux 8
Docker version 24.0.9
Using cgroups-v1

Edit 1: The path /sys/fs/cgroup/cpu/docker doesn't exist for me. I have paths /sys/fs/cgroup/cpu// for each docker container.

Share Improve this question edited Mar 19 at 13:00 Varun asked Mar 14 at 11:12 VarunVarun 4,2747 gold badges33 silver badges55 bronze badges 1
  • Isn't the path for container quota is /sys/fs/cgroup/cpu/docker/<container id>/cpu.cfs_quota_us instead of /sys/fs/cgroup/cpu/<container-name>/? – vht981230 Commented Mar 18 at 3:20
Add a comment  | 

2 Answers 2

Reset to default 1

You are using the wrong path. Use /sys/fs/cgroup/cpu/docker/<container id>/cpu.cfs_quota_us instead. This is backed up by a maintainer of a Docker package.

I found that for each docker container there is a path

/sys/fs/cgroup/cpu/system.slice/docker-<container-id>.scope/ path on the host VM. The files under this path contain the correct values.

For ex:

$ cat /sys/fs/cgroup/cpu/system.slice/docker-c4cf84223f98a00cede2420cff8d0039ebff57ba1b050206535d3ebfe682ee28.scope/cpu.cfs_quota_us

200000

$ cat /sys/fs/cgroup/cpu/system.slice/docker-c4cf84223f98a00cede2420cff8d0039ebff57ba1b050206535d3ebfe682ee28.scope/cpu.stat

nr_periods 2258489
nr_throttled 9724
throttled_time 836123329178

本文标签: sysfscgroupcpu path on host doesn39t show the cpu quota value set for docker containerStack Overflow