Merge pull request #4565 from shin-/onorua-pids-limit

Add pids_limit to service config
This commit is contained in:
Joffrey F 2017-03-06 18:09:53 -08:00 committed by GitHub
commit b454268f93
4 changed files with 12 additions and 0 deletions

View File

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

View File

@ -223,6 +223,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

@ -67,6 +67,7 @@ DOCKER_START_KEYS = [
'oom_score_adj',
'mem_swappiness',
'pid',
'pids_limit',
'privileged',
'restart',
'security_opt',
@ -774,6 +775,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,14 @@ class ServiceTest(DockerClientTestCase):
service.start_container(container)
self.assertEqual(container.get('HostConfig.ShmSize'), 67108864)
@pytest.mark.xfail(True, reason='Some kernels/configs do not support pids_limit')
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)
assert 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)