summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <f.joffrey@gmail.com>2017-06-16 12:05:15 -0700
committerGitHub <noreply@github.com>2017-06-16 12:05:15 -0700
commit2086c20ce16b71b4278bc2c7533a955d9a9545d3 (patch)
tree17aa5ae85605cc25403ed33035048d7a0d318a29
parent87d5cd1b0a172c1fc430736024996fee1580a241 (diff)
parent612c0f3d0de298884b80766d285f8ad47ad742a0 (diff)
downloaddocker-py-2086c20ce16b71b4278bc2c7533a955d9a9545d3.tar.gz
Merge pull request #1631 from madhuri-rai07/master
Add support for ``runtime`` config
-rw-r--r--docker/api/container.py6
-rw-r--r--docker/models/containers.py2
-rw-r--r--docker/types/containers.py12
-rw-r--r--tests/integration/api_container_test.py9
4 files changed, 24 insertions, 5 deletions
diff --git a/docker/api/container.py b/docker/api/container.py
index 7aeea20..97a39b6 100644
--- a/docker/api/container.py
+++ b/docker/api/container.py
@@ -238,7 +238,7 @@ class ContainerApiMixin(object):
memswap_limit=None, cpuset=None, host_config=None,
mac_address=None, labels=None, volume_driver=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
run`` command except it doesn't support the attach options (``-a``).
@@ -417,6 +417,7 @@ class ContainerApiMixin(object):
Default: 10
networking_config (dict): A networking configuration generated
by :py:meth:`create_networking_config`.
+ runtime (str): Runtime to use with this container.
Returns:
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,
memswap_limit, cpuset, host_config, mac_address, labels,
volume_driver, stop_signal, networking_config, healthcheck,
- stop_timeout
+ stop_timeout, runtime
)
return self.create_container_from_config(config, name)
@@ -576,6 +577,7 @@ class ContainerApiMixin(object):
values are: ``host``
volumes_from (:py:class:`list`): List of container names or IDs to
get volumes from.
+ runtime (str): Runtime to use with this container.
Returns:
diff --git a/docker/models/containers.py b/docker/models/containers.py
index 4bb2cf8..300c5a9 100644
--- a/docker/models/containers.py
+++ b/docker/models/containers.py
@@ -659,6 +659,7 @@ class ContainerCollection(Collection):
volumes_from (:py:class:`list`): List of container names or IDs to
get volumes from.
working_dir (str): Path to the working directory.
+ runtime (str): Runtime to use with this container.
Returns:
The container logs, either ``STDOUT``, ``STDERR``, or both,
@@ -885,6 +886,7 @@ RUN_HOST_CONFIG_KWARGS = [
'userns_mode',
'version',
'volumes_from',
+ 'runtime'
]
diff --git a/docker/types/containers.py b/docker/types/containers.py
index f33c5e8..6bbb57a 100644
--- a/docker/types/containers.py
+++ b/docker/types/containers.py
@@ -120,7 +120,7 @@ class HostConfig(dict):
isolation=None, auto_remove=False, storage_opt=None,
init=None, init_path=None, volume_driver=None,
cpu_count=None, cpu_percent=None, nano_cpus=None,
- cpuset_mems=None):
+ cpuset_mems=None, runtime=None):
if mem_limit is not None:
self['Memory'] = parse_bytes(mem_limit)
@@ -473,6 +473,11 @@ class HostConfig(dict):
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):
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,
host_config=None, mac_address=None, labels=None, volume_driver=None,
stop_signal=None, networking_config=None, healthcheck=None,
- stop_timeout=None
+ stop_timeout=None, runtime=None
):
if version_gte(version, '1.10'):
message = ('{0!r} parameter has no effect on create_container().'
@@ -659,5 +664,6 @@ class ContainerConfig(dict):
'VolumeDriver': volume_driver,
'StopSignal': stop_signal,
'Healthcheck': healthcheck,
- 'StopTimeout': stop_timeout
+ 'StopTimeout': stop_timeout,
+ 'Runtime': runtime
})
diff --git a/tests/integration/api_container_test.py b/tests/integration/api_container_test.py
index fb4c4e4..de3fe71 100644
--- a/tests/integration/api_container_test.py
+++ b/tests/integration/api_container_test.py
@@ -1255,6 +1255,15 @@ class ContainerCPUTest(BaseAPIIntegrationTest):
inspect_data = self.client.inspect_container(container)
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):
def test_remove_link(self):