Setting Docker's deploy.resources.limits.cpus with an unknown number of cores?

xuo3flqw  于 2022-12-11  发布在  Docker
关注(0)|答案(1)|浏览(124)

It's plausible that machines in a cluster have different numbers of cores. Docker Swarm mode's deploy.resources.limits.cpus config specifies the absolute number of cores. Is it possible to specify a percentage of the total available CPU resources? I want the total CPU limit to be close to 100% of the max capacity.
dockerfile snippet:

  1. deploy:
  2. resources:
  3. limits:
  4. cpus: '1'
  5. memory: 4G
pxiryf3j

pxiryf3j1#

没有。
如果您的服务实际上可以从多个核心中获益,请将cpu限制设置为节点可用的最小和最大核心的合理公约数,然后将副本设置为一个数字,使deploy. replica * deploy.resource.limits.cpus ~= total-swarm-cpus。

相关问题