Do --limit-xxx options of service command limit re

2019-05-25 21:59发布

问题:

service create command of docker 1.12 has two options to limit cpu and memory as follows:

  --limit-cpu value              Limit CPUs (default 0.000)
  --limit-memory value           Limit Memory (default 0 B)

Do they limit resource per service or per container?

回答1:

You can see in api/client/service/update.go

taskResources().Limits = &swarm.Resources{}
updateInt64Value(flagLimitCPU, &task.Resources.Limits.NanoCPUs)

--limit-cpu was introduced in commit 12a00e6

Considering that swarmkit/manager/scheduler/nodeinfo.go has, when removing a task, the following code:

nodeInfo.AvailableResources.NanoCPUs += reservations.NanoCPUs

It appears limit-cpu is per node managed by a service.



标签: docker