mirror of https://github.com/docker/docker-py.git
Merge branch 'tmad-container-init'
This commit is contained in:
commit
830b9edce8
|
@ -498,6 +498,9 @@ class ContainerApiMixin(object):
|
||||||
container, as a mapping of hostname to IP address.
|
container, as a mapping of hostname to IP address.
|
||||||
group_add (:py:class:`list`): List of additional group names and/or
|
group_add (:py:class:`list`): List of additional group names and/or
|
||||||
IDs that the container process will run as.
|
IDs that the container process will run as.
|
||||||
|
init (bool): Run an init inside the container that forwards
|
||||||
|
signals and reaps processes
|
||||||
|
init_path (str): Path to the docker-init binary
|
||||||
ipc_mode (str): Set the IPC mode for the container.
|
ipc_mode (str): Set the IPC mode for the container.
|
||||||
isolation (str): Isolation technology to use. Default: `None`.
|
isolation (str): Isolation technology to use. Default: `None`.
|
||||||
links (dict or list of tuples): Either a dictionary mapping name
|
links (dict or list of tuples): Either a dictionary mapping name
|
||||||
|
|
|
@ -491,6 +491,9 @@ class ContainerCollection(Collection):
|
||||||
group_add (:py:class:`list`): List of additional group names and/or
|
group_add (:py:class:`list`): List of additional group names and/or
|
||||||
IDs that the container process will run as.
|
IDs that the container process will run as.
|
||||||
hostname (str): Optional hostname for the container.
|
hostname (str): Optional hostname for the container.
|
||||||
|
init (bool): Run an init inside the container that forwards
|
||||||
|
signals and reaps processes
|
||||||
|
init_path (str): Path to the docker-init binary
|
||||||
ipc_mode (str): Set the IPC mode for the container.
|
ipc_mode (str): Set the IPC mode for the container.
|
||||||
isolation (str): Isolation technology to use. Default: `None`.
|
isolation (str): Isolation technology to use. Default: `None`.
|
||||||
labels (dict or list): A dictionary of name-value labels (e.g.
|
labels (dict or list): A dictionary of name-value labels (e.g.
|
||||||
|
@ -814,6 +817,8 @@ RUN_HOST_CONFIG_KWARGS = [
|
||||||
'dns',
|
'dns',
|
||||||
'extra_hosts',
|
'extra_hosts',
|
||||||
'group_add',
|
'group_add',
|
||||||
|
'init',
|
||||||
|
'init_path',
|
||||||
'ipc_mode',
|
'ipc_mode',
|
||||||
'isolation',
|
'isolation',
|
||||||
'kernel_memory',
|
'kernel_memory',
|
||||||
|
|
|
@ -117,7 +117,8 @@ class HostConfig(dict):
|
||||||
oom_kill_disable=False, shm_size=None, sysctls=None,
|
oom_kill_disable=False, shm_size=None, sysctls=None,
|
||||||
tmpfs=None, oom_score_adj=None, dns_opt=None, cpu_shares=None,
|
tmpfs=None, oom_score_adj=None, dns_opt=None, cpu_shares=None,
|
||||||
cpuset_cpus=None, userns_mode=None, pids_limit=None,
|
cpuset_cpus=None, userns_mode=None, pids_limit=None,
|
||||||
isolation=None, auto_remove=False, storage_opt=None):
|
isolation=None, auto_remove=False, storage_opt=None,
|
||||||
|
init=None, init_path=None):
|
||||||
|
|
||||||
if mem_limit is not None:
|
if mem_limit is not None:
|
||||||
self['Memory'] = parse_bytes(mem_limit)
|
self['Memory'] = parse_bytes(mem_limit)
|
||||||
|
@ -417,6 +418,16 @@ class HostConfig(dict):
|
||||||
raise host_config_version_error('storage_opt', '1.24')
|
raise host_config_version_error('storage_opt', '1.24')
|
||||||
self['StorageOpt'] = storage_opt
|
self['StorageOpt'] = storage_opt
|
||||||
|
|
||||||
|
if init is not None:
|
||||||
|
if version_lt(version, '1.25'):
|
||||||
|
raise host_config_version_error('init', '1.25')
|
||||||
|
self['Init'] = init
|
||||||
|
|
||||||
|
if init_path is not None:
|
||||||
|
if version_lt(version, '1.25'):
|
||||||
|
raise host_config_version_error('init_path', '1.25')
|
||||||
|
self['InitPath'] = init_path
|
||||||
|
|
||||||
|
|
||||||
def host_config_type_error(param, param_value, expected):
|
def host_config_type_error(param, param_value, expected):
|
||||||
error_msg = 'Invalid type for {0} param: expected {1} but found {2}'
|
error_msg = 'Invalid type for {0} param: expected {1} but found {2}'
|
||||||
|
|
|
@ -439,6 +439,30 @@ class CreateContainerTest(BaseAPIIntegrationTest):
|
||||||
'size': '120G'
|
'size': '120G'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@requires_api_version('1.25')
|
||||||
|
def test_create_with_init(self):
|
||||||
|
ctnr = self.client.create_container(
|
||||||
|
BUSYBOX, 'true',
|
||||||
|
host_config=self.client.create_host_config(
|
||||||
|
init=True
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.tmp_containers.append(ctnr['Id'])
|
||||||
|
config = self.client.inspect_container(ctnr)
|
||||||
|
assert config['HostConfig']['Init'] is True
|
||||||
|
|
||||||
|
@requires_api_version('1.25')
|
||||||
|
def test_create_with_init_path(self):
|
||||||
|
ctnr = self.client.create_container(
|
||||||
|
BUSYBOX, 'true',
|
||||||
|
host_config=self.client.create_host_config(
|
||||||
|
init_path="/usr/libexec/docker-init"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.tmp_containers.append(ctnr['Id'])
|
||||||
|
config = self.client.inspect_container(ctnr)
|
||||||
|
assert config['HostConfig']['InitPath'] == "/usr/libexec/docker-init"
|
||||||
|
|
||||||
|
|
||||||
class VolumeBindTest(BaseAPIIntegrationTest):
|
class VolumeBindTest(BaseAPIIntegrationTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
Loading…
Reference in New Issue