summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <f.joffrey@gmail.com>2017-12-13 16:45:35 -0800
committerGitHub <noreply@github.com>2017-12-13 16:45:35 -0800
commit6f77e458d27baa6c7ef05806f2bf25ceec9f630b (patch)
tree21e64d1fde03c2f2ed0fd9161728e3273c3967d6
parentaad0c760026abf4283e772d729889ba58c343e7d (diff)
parentf3dbd017f8c41774f7176319ba1d80a8a1101593 (diff)
downloaddocker-py-6f77e458d27baa6c7ef05806f2bf25ceec9f630b.tar.gz
Merge pull request #1816 from Anvil/honor-stoptimeout
Fix for #1815: make APIClient.stop honor container StopTimeout value
-rw-r--r--docker/api/container.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/docker/api/container.py b/docker/api/container.py
index 8dd89cc..5d58851 100644
--- a/docker/api/container.py
+++ b/docker/api/container.py
@@ -1113,20 +1113,26 @@ class ContainerApiMixin(object):
json=True)
@utils.check_resource('container')
- def stop(self, container, timeout=10):
+ def stop(self, container, timeout=None):
"""
Stops a container. Similar to the ``docker stop`` command.
Args:
container (str): The container to stop
timeout (int): Timeout in seconds to wait for the container to
- stop before sending a ``SIGKILL``. Default: 10
+ stop before sending a ``SIGKILL``. If None, then the
+ StopTimeout value of the container will be used.
+ Default: None
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
- params = {'t': timeout}
+ if timeout is None:
+ params = {}
+ timeout = 10
+ else:
+ params = {'t': timeout}
url = self._url("/containers/{0}/stop", container)
res = self._post(url, params=params,