From 75e53f1add3ab5f57984938d346d23e3be840546 Mon Sep 17 00:00:00 2001 From: Patrick Hensley Date: Sat, 4 Oct 2014 23:14:24 -0400 Subject: [PATCH] Added pause/unpause methods. --- README.md | 12 ++++++++++++ docker/client.py | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/README.md b/README.md index 52139b21..659c26c7 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,12 @@ The `logs` function is a wrapper around this one, which you can use instead if you want to fetch/stream container output without first retrieving the entire backlog. +```python +c.pause(container) +``` + +Pauses all processes within a container. + ```python c.ping() ``` @@ -307,6 +313,12 @@ c.top(container) Identical to the `docker top` command. +```python +c.unpause(container) +``` + +Unpauses all processes within a container. + ```python c.version() ``` diff --git a/docker/client.py b/docker/client.py index 1ff43cc4..b07796a5 100644 --- a/docker/client.py +++ b/docker/client.py @@ -696,6 +696,13 @@ class Client(requests.Session): logs=True ) + def pause(self, container): + if isinstance(container, dict): + container = container.get('Id') + url = self._url('/containers/{0}/pause'.format(container)) + res = self._post(url) + self._raise_for_status(res) + def ping(self): return self._result(self._get(self._url('/_ping'))) @@ -922,6 +929,13 @@ class Client(requests.Session): def version(self): return self._result(self._get(self._url("/version")), True) + def unpause(self, container): + if isinstance(container, dict): + container = container.get('Id') + url = self._url('/containers/{0}/unpause'.format(container)) + res = self._post(url) + self._raise_for_status(res) + def wait(self, container): if isinstance(container, dict): container = container.get('Id')