mirror of https://github.com/docker/compose.git
Merge pull request #2552 from dbonev/2452-implement-cpu-quota
Added support for cpu_quota flag
This commit is contained in:
commit
100d6f2fbb
|
@ -31,6 +31,7 @@ DOCKER_CONFIG_KEYS = [
|
||||||
'cap_drop',
|
'cap_drop',
|
||||||
'cgroup_parent',
|
'cgroup_parent',
|
||||||
'command',
|
'command',
|
||||||
|
'cpu_quota',
|
||||||
'cpu_shares',
|
'cpu_shares',
|
||||||
'cpuset',
|
'cpuset',
|
||||||
'detach',
|
'detach',
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
},
|
},
|
||||||
"container_name": {"type": "string"},
|
"container_name": {"type": "string"},
|
||||||
"cpu_shares": {"type": ["number", "string"]},
|
"cpu_shares": {"type": ["number", "string"]},
|
||||||
|
"cpu_quota": {"type": ["number", "string"]},
|
||||||
"cpuset": {"type": "string"},
|
"cpuset": {"type": "string"},
|
||||||
"devices": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
|
"devices": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
|
||||||
"dns": {"$ref": "#/definitions/string_or_list"},
|
"dns": {"$ref": "#/definitions/string_or_list"},
|
||||||
|
|
|
@ -59,6 +59,7 @@ DOCKER_START_KEYS = [
|
||||||
'restart',
|
'restart',
|
||||||
'volumes_from',
|
'volumes_from',
|
||||||
'security_opt',
|
'security_opt',
|
||||||
|
'cpu_quota',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -610,6 +611,7 @@ class Service(object):
|
||||||
security_opt=options.get('security_opt'),
|
security_opt=options.get('security_opt'),
|
||||||
ipc_mode=options.get('ipc'),
|
ipc_mode=options.get('ipc'),
|
||||||
cgroup_parent=options.get('cgroup_parent'),
|
cgroup_parent=options.get('cgroup_parent'),
|
||||||
|
cpu_quota=options.get('cpu_quota'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, no_cache=False, pull=False, force_rm=False):
|
def build(self, no_cache=False, pull=False, force_rm=False):
|
||||||
|
|
|
@ -385,12 +385,13 @@ specifying read-only access(``ro``) or read-write(``rw``).
|
||||||
- container_name
|
- container_name
|
||||||
- service_name:rw
|
- service_name:rw
|
||||||
|
|
||||||
### cpu\_shares, cpuset, domainname, entrypoint, hostname, ipc, mac\_address, mem\_limit, memswap\_limit, privileged, read\_only, restart, stdin\_open, tty, user, working\_dir
|
### cpu\_shares, cpu\_quota, cpuset, domainname, entrypoint, hostname, ipc, mac\_address, mem\_limit, memswap\_limit, privileged, read\_only, restart, stdin\_open, tty, user, working\_dir
|
||||||
|
|
||||||
Each of these is a single value, analogous to its
|
Each of these is a single value, analogous to its
|
||||||
[docker run](https://docs.docker.com/reference/run/) counterpart.
|
[docker run](https://docs.docker.com/reference/run/) counterpart.
|
||||||
|
|
||||||
cpu_shares: 73
|
cpu_shares: 73
|
||||||
|
cpu_quota: 50000
|
||||||
cpuset: 0,1
|
cpuset: 0,1
|
||||||
|
|
||||||
entrypoint: /code/entrypoint.sh
|
entrypoint: /code/entrypoint.sh
|
||||||
|
|
|
@ -102,6 +102,12 @@ class ServiceTest(DockerClientTestCase):
|
||||||
container.start()
|
container.start()
|
||||||
self.assertEqual(container.get('HostConfig.CpuShares'), 73)
|
self.assertEqual(container.get('HostConfig.CpuShares'), 73)
|
||||||
|
|
||||||
|
def test_create_container_with_cpu_quota(self):
|
||||||
|
service = self.create_service('db', cpu_quota=40000)
|
||||||
|
container = service.create_container()
|
||||||
|
container.start()
|
||||||
|
self.assertEqual(container.get('HostConfig.CpuQuota'), 40000)
|
||||||
|
|
||||||
def test_create_container_with_extra_hosts_list(self):
|
def test_create_container_with_extra_hosts_list(self):
|
||||||
extra_hosts = ['somehost:162.242.195.82', 'otherhost:50.31.209.229']
|
extra_hosts = ['somehost:162.242.195.82', 'otherhost:50.31.209.229']
|
||||||
service = self.create_service('db', extra_hosts=extra_hosts)
|
service = self.create_service('db', extra_hosts=extra_hosts)
|
||||||
|
|
Loading…
Reference in New Issue