Skip to content

Commit 6a151aa

Browse files
onoruashin-
authored andcommitted
introducing pids_limit, fix for #4178
Signed-off-by: Yaroslav Molochko <[email protected]>
1 parent 31b2d91 commit 6a151aa

5 files changed

Lines changed: 12 additions & 0 deletions

File tree

compose/config/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
'secrets',
8888
'security_opt',
8989
'shm_size',
90+
'pids_limit',
9091
'stdin_open',
9192
'stop_signal',
9293
'sysctls',

compose/config/config_schema_v2.1.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
217217
"shm_size": {"type": ["number", "string"]},
218218
"sysctls": {"$ref": "#/definitions/list_or_dict"},
219+
"pids_limit": {"type": ["number", "string"]},
219220
"stdin_open": {"type": "boolean"},
220221
"stop_grace_period": {"type": "string", "format": "duration"},
221222
"stop_signal": {"type": "string"},

compose/config/config_schema_v3.0.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
169169
"shm_size": {"type": ["number", "string"]},
170170
"sysctls": {"$ref": "#/definitions/list_or_dict"},
171+
"pids_limit": {"type": ["number", "string"]},
171172
"stdin_open": {"type": "boolean"},
172173
"stop_grace_period": {"type": "string", "format": "duration"},
173174
"stop_signal": {"type": "string"},

compose/service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
'oom_score_adj',
6767
'mem_swappiness',
6868
'pid',
69+
'pids_limit',
6970
'privileged',
7071
'restart',
7172
'security_opt',
@@ -772,6 +773,7 @@ def _get_container_host_config(self, override_options, one_off=False):
772773
cpu_quota=options.get('cpu_quota'),
773774
shm_size=options.get('shm_size'),
774775
sysctls=options.get('sysctls'),
776+
pids_limit=options.get('pids_limit'),
775777
tmpfs=options.get('tmpfs'),
776778
oom_score_adj=options.get('oom_score_adj'),
777779
mem_swappiness=options.get('mem_swappiness'),

tests/integration/service_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ def test_create_container_with_shm_size(self):
115115
service.start_container(container)
116116
self.assertEqual(container.get('HostConfig.ShmSize'), 67108864)
117117

118+
def test_create_container_with_pids_limit(self):
119+
self.require_api_version('1.23')
120+
service = self.create_service('db', pids_limit=10)
121+
container = service.create_container()
122+
service.start_container(container)
123+
self.assertEqual(container.get('HostConfig.PidsLimit'), 10)
124+
118125
def test_create_container_with_extra_hosts_list(self):
119126
extra_hosts = ['somehost:162.242.195.82', 'otherhost:50.31.209.229']
120127
service = self.create_service('db', extra_hosts=extra_hosts)

0 commit comments

Comments
 (0)