mirror of https://github.com/docker/docker-py.git
added stop_signal to create container config
Signed-off-by: Jonathan Stewmon <jstewmon@rmn.com>
This commit is contained in:
parent
b5fb6d216f
commit
31b1b53f7f
|
@ -97,7 +97,8 @@ class ContainerApiMixin(object):
|
|||
network_disabled=False, name=None, entrypoint=None,
|
||||
cpu_shares=None, working_dir=None, domainname=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):
|
||||
|
||||
if isinstance(volumes, six.string_types):
|
||||
volumes = [volumes, ]
|
||||
|
@ -112,7 +113,7 @@ class ContainerApiMixin(object):
|
|||
tty, mem_limit, ports, environment, dns, volumes, volumes_from,
|
||||
network_disabled, entrypoint, cpu_shares, working_dir, domainname,
|
||||
memswap_limit, cpuset, host_config, mac_address, labels,
|
||||
volume_driver
|
||||
volume_driver, stop_signal
|
||||
)
|
||||
return self.create_container_from_config(config, name)
|
||||
|
||||
|
|
|
@ -704,7 +704,7 @@ def create_container_config(
|
|||
dns=None, volumes=None, volumes_from=None, network_disabled=False,
|
||||
entrypoint=None, cpu_shares=None, working_dir=None, domainname=None,
|
||||
memswap_limit=None, cpuset=None, host_config=None, mac_address=None,
|
||||
labels=None, volume_driver=None
|
||||
labels=None, volume_driver=None, stop_signal=None
|
||||
):
|
||||
if isinstance(command, six.string_types):
|
||||
command = split_command(command)
|
||||
|
@ -723,6 +723,11 @@ def create_container_config(
|
|||
'labels were only introduced in API version 1.18'
|
||||
)
|
||||
|
||||
if stop_signal is not None and compare_version('1.21', version) < 0:
|
||||
raise errors.InvalidVersion(
|
||||
'stop_signal was only introduced in API version 1.21'
|
||||
)
|
||||
|
||||
if compare_version('1.19', version) < 0:
|
||||
if volume_driver is not None:
|
||||
raise errors.InvalidVersion(
|
||||
|
@ -828,4 +833,5 @@ def create_container_config(
|
|||
'MacAddress': mac_address,
|
||||
'Labels': labels,
|
||||
'VolumeDriver': volume_driver,
|
||||
'StopSignal': stop_signal
|
||||
}
|
||||
|
|
|
@ -224,6 +224,7 @@ from. Optionally a single string joining container id's with commas
|
|||
* mac_address (str): The Mac Address to assign the container
|
||||
* labels (dict or list): A dictionary of name-value labels (e.g. `{"label1": "value1", "label2": "value2"}`) or a list of names of labels to set with empty values (e.g. `["label1", "label2"]`)
|
||||
* volume_driver (str): The name of a volume driver/plugin.
|
||||
* stop_signal (str): The stop signal to use to stop the container (e.g. `SIGINT`).
|
||||
|
||||
**Returns** (dict): A dictionary with an image 'Id' key and a 'Warnings' key.
|
||||
|
||||
|
|
|
@ -964,6 +964,25 @@ class CreateContainerTest(DockerClientTest):
|
|||
DEFAULT_TIMEOUT_SECONDS
|
||||
)
|
||||
|
||||
def test_create_container_with_stop_signal(self):
|
||||
self.client.create_container('busybox', 'ls',
|
||||
stop_signal='SIGINT')
|
||||
|
||||
args = fake_request.call_args
|
||||
self.assertEqual(args[0][1],
|
||||
url_prefix + 'containers/create')
|
||||
self.assertEqual(json.loads(args[1]['data']),
|
||||
json.loads('''
|
||||
{"Tty": false, "Image": "busybox",
|
||||
"Cmd": ["ls"], "AttachStdin": false,
|
||||
"AttachStderr": true,
|
||||
"AttachStdout": true, "OpenStdin": false,
|
||||
"StdinOnce": false,
|
||||
"NetworkDisabled": false,
|
||||
"StopSignal": "SIGINT"}'''))
|
||||
self.assertEqual(args[1]['headers'],
|
||||
{'Content-Type': 'application/json'})
|
||||
|
||||
|
||||
class ContainerTest(DockerClientTest):
|
||||
def test_list_containers(self):
|
||||
|
|
Loading…
Reference in New Issue