mirror of https://github.com/docker/docker-py.git
commit
bba8e28f82
|
@ -556,7 +556,8 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
|
|||
security_opt=None, ulimits=None, log_config=None,
|
||||
mem_limit=None, memswap_limit=None, mem_swappiness=None,
|
||||
cgroup_parent=None, group_add=None, cpu_quota=None,
|
||||
cpu_period=None, oom_kill_disable=False, version=None):
|
||||
cpu_period=None, oom_kill_disable=False, shm_size=None,
|
||||
version=None):
|
||||
|
||||
host_config = {}
|
||||
|
||||
|
@ -589,6 +590,12 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
|
|||
|
||||
host_config['MemorySwappiness'] = mem_swappiness
|
||||
|
||||
if shm_size is not None:
|
||||
if isinstance(shm_size, six.string_types):
|
||||
shm_size = parse_bytes(shm_size)
|
||||
|
||||
host_config['ShmSize'] = shm_size
|
||||
|
||||
if pid_mode not in (None, 'host'):
|
||||
raise host_config_value_error('pid_mode', pid_mode)
|
||||
elif pid_mode:
|
||||
|
|
|
@ -103,6 +103,7 @@ for example:
|
|||
allowed to consume.
|
||||
* mem_swappiness (int): Tune a container's memory swappiness behavior.
|
||||
Accepts number between 0 and 100.
|
||||
* shm_size (str or int): Size of /dev/shm. (e.g. `'1G'`)
|
||||
* cpu_group (int): The length of a CPU period in microseconds.
|
||||
* cpu_period (int): Microseconds of CPU time that the container can get in a
|
||||
CPU period.
|
||||
|
|
|
@ -64,6 +64,14 @@ class HostConfigTest(base.BaseTestCase):
|
|||
config = create_host_config(version='1.20', cpu_period=1999)
|
||||
self.assertEqual(config.get('CpuPeriod'), 1999)
|
||||
|
||||
def test_create_host_config_with_shm_size(self):
|
||||
config = create_host_config(version='1.22', shm_size=67108864)
|
||||
self.assertEqual(config.get('ShmSize'), 67108864)
|
||||
|
||||
def test_create_host_config_with_shm_size_in_mb(self):
|
||||
config = create_host_config(version='1.22', shm_size='64M')
|
||||
self.assertEqual(config.get('ShmSize'), 67108864)
|
||||
|
||||
def test_create_host_config_with_oom_kill_disable(self):
|
||||
config = create_host_config(version='1.20', oom_kill_disable=True)
|
||||
self.assertEqual(config.get('OomKillDisable'), True)
|
||||
|
|
Loading…
Reference in New Issue