mirror of https://github.com/docker/docker-py.git
Add support for ``runtime`` in container create and run API
This commit is contained in:
parent
dc2b24dcdd
commit
6ae24b9e60
|
@ -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): The name of the runtime tool to create 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): The name of the runtime tool to manage 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): The name of the runtime tool to create 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,9 @@ class HostConfig(dict):
|
||||||
|
|
||||||
self['NanoCpus'] = nano_cpus
|
self['NanoCpus'] = nano_cpus
|
||||||
|
|
||||||
|
if runtime:
|
||||||
|
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 +502,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 +662,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
|
||||||
})
|
})
|
||||||
|
|
|
@ -122,6 +122,8 @@ Change log
|
||||||
* Added support for `force_update` in `TaskTemplate`
|
* Added support for `force_update` in `TaskTemplate`
|
||||||
* Made `name` parameter optional in `APIClient.create_volume` and
|
* Made `name` parameter optional in `APIClient.create_volume` and
|
||||||
`DockerClient.volumes.create`
|
`DockerClient.volumes.create`
|
||||||
|
* Added support for `runtime` in `APIClient.create_container` and
|
||||||
|
`DockerClient.containers.run`
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
|
|
@ -1256,6 +1256,15 @@ class ContainerCPUTest(BaseAPIIntegrationTest):
|
||||||
self.assertEqual(inspect_data['HostConfig']['CpusetCpus'], cpuset_cpus)
|
self.assertEqual(inspect_data['HostConfig']['CpusetCpus'], cpuset_cpus)
|
||||||
|
|
||||||
|
|
||||||
|
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['Config']['Runtime'] == 'runc'
|
||||||
|
|
||||||
|
|
||||||
class LinkTest(BaseAPIIntegrationTest):
|
class LinkTest(BaseAPIIntegrationTest):
|
||||||
def test_remove_link(self):
|
def test_remove_link(self):
|
||||||
# Create containers
|
# Create containers
|
||||||
|
|
Loading…
Reference in New Issue