Docker service Limits and Reservations

2019-04-04 19:40发布

Docker v1.12 service comes with four flags for setting the resource limits on a service.

--limit-cpu value Limit CPUs (default 0.000)

--limit-memory value Limit Memory (default 0 B)

--reserve-cpu value Reserve CPUs (default 0.000)

--reserve-memory value Reserve Memory (default 0 B)

  1. What is the difference between limit and reserve in this context?

  2. What does the cpu value mean in here? Does this mean number of cores? cpu share? What is the unit?

标签: docker
1条回答
放我归山
2楼-- · 2019-04-04 20:09

Reserve holds those resources on the host so they are always available for the container. Think dedicated resources.

Limit prevents the binary inside the container from using more than that. Think of controlling runaway processes in container.

Based on my limited testing with stress, --limit-cpu is percent of a core, though if there are multiple threads, it'll spread those out across core's and seems to attempt to keep the total near what you'd expect.

In the below pic, from left to right, was --limit-cpu 4, then 2.5, then 2, then 1. All of those tests had stress set to CPU of 4 (worker threads).

enter image description here

查看更多
登录 后发表回答