introducing pids_limit, fix for #4178

Signed-off-by: Yaroslav Molochko <y.molochko@anchorfree.com>
This commit is contained in:
Yaroslav Molochko 2016-11-23 12:12:57 -08:00 committed by Joffrey F
parent 31b2d9176b
commit 6a151aac04
5 changed files with 12 additions and 0 deletions

View File

@ -87,6 +87,7 @@ DOCKER_CONFIG_KEYS = [
'secrets',
'security_opt',
'shm_size',
'pids_limit',
'stdin_open',
'stop_signal',
'sysctls',

View File

@ -216,6 +216,7 @@
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"shm_size": {"type": ["number", "string"]},
"sysctls": {"$ref": "#/definitions/list_or_dict"},
"pids_limit": {"type": ["number", "string"]},
"stdin_open": {"type": "boolean"},
"stop_grace_period": {"type": "string", "format": "duration"},
"stop_signal": {"type": "string"},

View File

@ -168,6 +168,7 @@
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"shm_size": {"type": ["number", "string"]},
"sysctls": {"$ref": "#/definitions/list_or_dict"},
"pids_limit": {"type": ["number", "string"]},
"stdin_open": {"type": "boolean"},
"stop_grace_period": {"type": "string", "format": "duration"},
"stop_signal": {"type": "string"},

View File

@ -66,6 +66,7 @@ DOCKER_START_KEYS = [
'oom_score_adj',
'mem_swappiness',
'pid',
'pids_limit',
'privileged',
'restart',
'security_opt',
@ -772,6 +773,7 @@ class Service(object):
cpu_quota=options.get('cpu_quota'),
shm_size=options.get('shm_size'),
sysctls=options.get('sysctls'),
pids_limit=options.get('pids_limit'),
tmpfs=options.get('tmpfs'),
oom_score_adj=options.get('oom_score_adj'),
mem_swappiness=options.get('mem_swappiness'),

View File

@ -115,6 +115,13 @@ class ServiceTest(DockerClientTestCase):
service.start_container(container)
self.assertEqual(container.get('HostConfig.ShmSize'), 67108864)
def test_create_container_with_pids_limit(self):
self.require_api_version('1.23')
service = self.create_service('db', pids_limit=10)
container = service.create_container()
service.start_container(container)
self.assertEqual(container.get('HostConfig.PidsLimit'), 10)
def test_create_container_with_extra_hosts_list(self):
extra_hosts = ['somehost:162.242.195.82', 'otherhost:50.31.209.229']
service = self.create_service('db', extra_hosts=extra_hosts)