mirror of https://github.com/docker/docker-py.git
Merge pull request #1297 from docker/stepanstipl-allow_custom_pid_mode
Allow custom pid mode
This commit is contained in:
commit
9643253c50
|
@ -735,9 +735,9 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
|
|||
|
||||
host_config['ShmSize'] = shm_size
|
||||
|
||||
if pid_mode not in (None, 'host'):
|
||||
raise host_config_value_error('pid_mode', pid_mode)
|
||||
elif pid_mode:
|
||||
if pid_mode:
|
||||
if version_lt(version, '1.24') and pid_mode != 'host':
|
||||
raise host_config_value_error('pid_mode', pid_mode)
|
||||
host_config['PidMode'] = pid_mode
|
||||
|
||||
if ipc_mode:
|
||||
|
|
|
@ -361,13 +361,6 @@ class CreateContainerTest(BaseAPIIntegrationTest):
|
|||
host_config = inspect['HostConfig']
|
||||
self.assertIn('MemorySwappiness', host_config)
|
||||
|
||||
def test_create_host_config_exception_raising(self):
|
||||
self.assertRaises(TypeError,
|
||||
self.client.create_host_config, mem_swappiness='40')
|
||||
|
||||
self.assertRaises(ValueError,
|
||||
self.client.create_host_config, pid_mode='40')
|
||||
|
||||
def test_create_with_environment_variable_no_value(self):
|
||||
container = self.client.create_container(
|
||||
BUSYBOX,
|
||||
|
|
|
@ -205,6 +205,19 @@ class HostConfigTest(unittest.TestCase):
|
|||
version='1.24', isolation={'isolation': 'hyperv'}
|
||||
)
|
||||
|
||||
def test_create_host_config_pid_mode(self):
|
||||
with pytest.raises(ValueError):
|
||||
create_host_config(version='1.23', pid_mode='baccab125')
|
||||
|
||||
config = create_host_config(version='1.23', pid_mode='host')
|
||||
assert config.get('PidMode') == 'host'
|
||||
config = create_host_config(version='1.24', pid_mode='baccab125')
|
||||
assert config.get('PidMode') == 'baccab125'
|
||||
|
||||
def test_create_host_config_invalid_mem_swappiness(self):
|
||||
with pytest.raises(TypeError):
|
||||
create_host_config(version='1.24', mem_swappiness='40')
|
||||
|
||||
|
||||
class UlimitTest(unittest.TestCase):
|
||||
def test_create_host_config_dict_ulimit(self):
|
||||
|
|
Loading…
Reference in New Issue