Ben Chuanlong Du's Blog

It is never too late to learn.

Check the CPU Limit of a Docker Container

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. Get the number in the file /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us. Denote it as cfs_quota_us.

  2. Get the number in the file /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us. Denote it as cfs_period_us.

  3. Calculate the CPU limit (set by --cpus) as cfs_quota_us / cfs_period_us.

Comments