mirror of https://github.com/docker/docker-py.git
Merge pull request #1631 from madhuri-rai07/master
Add support for ``runtime`` config
This commit is contained in:
commit
2086c20ce1
|
@ -238,7 +238,7 @@ class ContainerApiMixin(object):
|
||||||
memswap_limit=None, cpuset=None, host_config=None,
|
memswap_limit=None, cpuset=None, host_config=None,
|
||||||
mac_address=None, labels=None, volume_driver=None,
|
mac_address=None, labels=None, volume_driver=None,
|
||||||
stop_signal=None, networking_config=None,
|
stop_signal=None, networking_config=None,
|
||||||
healthcheck=None, stop_timeout=None):
|
healthcheck=None, stop_timeout=None, runtime=None):
|
||||||
"""
|
"""
|
||||||
Creates a container. Parameters are similar to those for the ``docker
|
Creates a container. Parameters are similar to those for the ``docker
|
||||||
run`` command except it doesn't support the attach options (``-a``).
|
run`` command except it doesn't support the attach options (``-a``).
|
||||||
|
@ -417,6 +417,7 @@ class ContainerApiMixin(object):
|
||||||
Default: 10
|
Default: 10
|
||||||
networking_config (dict): A networking configuration generated
|
networking_config (dict): A networking configuration generated
|
||||||
by :py:meth:`create_networking_config`.
|
by :py:meth:`create_networking_config`.
|
||||||
|
runtime (str): Runtime to use with this container.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A dictionary with an image 'Id' key and a 'Warnings' key.
|
A dictionary with an image 'Id' key and a 'Warnings' key.
|
||||||
|
@ -441,7 +442,7 @@ class ContainerApiMixin(object):
|
||||||
network_disabled, entrypoint, cpu_shares, working_dir, domainname,
|
network_disabled, entrypoint, cpu_shares, working_dir, domainname,
|
||||||
memswap_limit, cpuset, host_config, mac_address, labels,
|
memswap_limit, cpuset, host_config, mac_address, labels,
|
||||||
volume_driver, stop_signal, networking_config, healthcheck,
|
volume_driver, stop_signal, networking_config, healthcheck,
|
||||||
stop_timeout
|
stop_timeout, runtime
|
||||||
)
|
)
|
||||||
return self.create_container_from_config(config, name)
|
return self.create_container_from_config(config, name)
|
||||||
|
|
||||||
|
@ -576,6 +577,7 @@ class ContainerApiMixin(object):
|
||||||
values are: ``host``
|
values are: ``host``
|
||||||
volumes_from (:py:class:`list`): List of container names or IDs to
|
volumes_from (:py:class:`list`): List of container names or IDs to
|
||||||
get volumes from.
|
get volumes from.
|
||||||
|
runtime (str): Runtime to use with this container.
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
@ -659,6 +659,7 @@ class ContainerCollection(Collection):
|
||||||
volumes_from (:py:class:`list`): List of container names or IDs to
|
volumes_from (:py:class:`list`): List of container names or IDs to
|
||||||
get volumes from.
|
get volumes from.
|
||||||
working_dir (str): Path to the working directory.
|
working_dir (str): Path to the working directory.
|
||||||
|
runtime (str): Runtime to use with this container.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The container logs, either ``STDOUT``, ``STDERR``, or both,
|
The container logs, either ``STDOUT``, ``STDERR``, or both,
|
||||||
|
@ -885,6 +886,7 @@ RUN_HOST_CONFIG_KWARGS = [
|
||||||
'userns_mode',
|
'userns_mode',
|
||||||
'version',
|
'version',
|
||||||
'volumes_from',
|
'volumes_from',
|
||||||
|
'runtime'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ class HostConfig(dict):
|
||||||
isolation=None, auto_remove=False, storage_opt=None,
|
isolation=None, auto_remove=False, storage_opt=None,
|
||||||
init=None, init_path=None, volume_driver=None,
|
init=None, init_path=None, volume_driver=None,
|
||||||
cpu_count=None, cpu_percent=None, nano_cpus=None,
|
cpu_count=None, cpu_percent=None, nano_cpus=None,
|
||||||
cpuset_mems=None):
|
cpuset_mems=None, runtime=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)
|
||||||
|
@ -473,6 +473,11 @@ class HostConfig(dict):
|
||||||
|
|
||||||
self['NanoCpus'] = nano_cpus
|
self['NanoCpus'] = nano_cpus
|
||||||
|
|
||||||
|
if runtime:
|
||||||
|
if version_lt(version, '1.25'):
|
||||||
|
raise host_config_version_error('runtime', '1.25')
|
||||||
|
self['Runtime'] = runtime
|
||||||
|
|
||||||
|
|
||||||
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}'
|
||||||
|
@ -499,7 +504,7 @@ class ContainerConfig(dict):
|
||||||
working_dir=None, domainname=None, memswap_limit=None, cpuset=None,
|
working_dir=None, domainname=None, memswap_limit=None, cpuset=None,
|
||||||
host_config=None, mac_address=None, labels=None, volume_driver=None,
|
host_config=None, mac_address=None, labels=None, volume_driver=None,
|
||||||
stop_signal=None, networking_config=None, healthcheck=None,
|
stop_signal=None, networking_config=None, healthcheck=None,
|
||||||
stop_timeout=None
|
stop_timeout=None, runtime=None
|
||||||
):
|
):
|
||||||
if version_gte(version, '1.10'):
|
if version_gte(version, '1.10'):
|
||||||
message = ('{0!r} parameter has no effect on create_container().'
|
message = ('{0!r} parameter has no effect on create_container().'
|
||||||
|
@ -659,5 +664,6 @@ class ContainerConfig(dict):
|
||||||
'VolumeDriver': volume_driver,
|
'VolumeDriver': volume_driver,
|
||||||
'StopSignal': stop_signal,
|
'StopSignal': stop_signal,
|
||||||
'Healthcheck': healthcheck,
|
'Healthcheck': healthcheck,
|
||||||
'StopTimeout': stop_timeout
|
'StopTimeout': stop_timeout,
|
||||||
|
'Runtime': runtime
|
||||||
})
|
})
|
||||||
|
|
|
@ -1255,6 +1255,15 @@ class ContainerCPUTest(BaseAPIIntegrationTest):
|
||||||
inspect_data = self.client.inspect_container(container)
|
inspect_data = self.client.inspect_container(container)
|
||||||
self.assertEqual(inspect_data['HostConfig']['CpusetCpus'], cpuset_cpus)
|
self.assertEqual(inspect_data['HostConfig']['CpusetCpus'], cpuset_cpus)
|
||||||
|
|
||||||
|
@requires_api_version('1.25')
|
||||||
|
def test_create_with_runtime(self):
|
||||||
|
container = self.client.create_container(
|
||||||
|
BUSYBOX, ['echo', 'test'], runtime='runc'
|
||||||
|
)
|
||||||
|
self.tmp_containers.append(container['Id'])
|
||||||
|
config = self.client.inspect_container(container)
|
||||||
|
assert config['HostConfig']['Runtime'] == 'runc'
|
||||||
|
|
||||||
|
|
||||||
class LinkTest(BaseAPIIntegrationTest):
|
class LinkTest(BaseAPIIntegrationTest):
|
||||||
def test_remove_link(self):
|
def test_remove_link(self):
|
||||||
|
|
Loading…
Reference in New Issue