Added ulimits functionality to docker compose
Signed-off-by: Kevin Greene <kevin@spantree.net>
This commit is contained in:
parent
7d6c63d1b7
commit
22d90d2180
6 changed files with 152 additions and 0 deletions
|
|
@ -676,6 +676,7 @@ class Service(object):
|
|||
|
||||
devices = options.get('devices', None)
|
||||
cgroup_parent = options.get('cgroup_parent', None)
|
||||
ulimits = build_ulimits(options.get('ulimits', None))
|
||||
|
||||
return self.client.create_host_config(
|
||||
links=self._get_links(link_to_self=one_off),
|
||||
|
|
@ -692,6 +693,7 @@ class Service(object):
|
|||
cap_drop=cap_drop,
|
||||
mem_limit=options.get('mem_limit'),
|
||||
memswap_limit=options.get('memswap_limit'),
|
||||
ulimits=ulimits,
|
||||
log_config=log_config,
|
||||
extra_hosts=extra_hosts,
|
||||
read_only=read_only,
|
||||
|
|
@ -1073,6 +1075,23 @@ def parse_restart_spec(restart_config):
|
|||
|
||||
return {'Name': name, 'MaximumRetryCount': int(max_retry_count)}
|
||||
|
||||
# Ulimits
|
||||
|
||||
|
||||
def build_ulimits(ulimit_config):
|
||||
if not ulimit_config:
|
||||
return None
|
||||
ulimits = []
|
||||
for limit_name, soft_hard_values in six.iteritems(ulimit_config):
|
||||
if isinstance(soft_hard_values, six.integer_types):
|
||||
ulimits.append({'name': limit_name, 'soft': soft_hard_values, 'hard': soft_hard_values})
|
||||
elif isinstance(soft_hard_values, dict):
|
||||
ulimit_dict = {'name': limit_name}
|
||||
ulimit_dict.update(soft_hard_values)
|
||||
ulimits.append(ulimit_dict)
|
||||
|
||||
return ulimits
|
||||
|
||||
|
||||
# Extra hosts
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue