最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

sysfscgroupcpu path on host doesn't show the cpu quota value set for docker container - Stack Overflow

programmeradmin2浏览0评论

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
发布评论

评论列表(0)

  1. 暂无评论