summaryrefslogtreecommitdiff
path: root/docker/api/container.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2017-01-27 17:59:09 -0800
committerJoffrey F <joffrey@docker.com>2017-01-30 18:53:46 -0800
commitf2a867f04b30489968a2dcffce9faff4db4af6ae (patch)
treeec394ecd436c4b151ea7f603b255b9313e9908c1 /docker/api/container.py
parentd3798b157c9ec89da49580511421db3ffe3c6c73 (diff)
downloaddocker-py-f2a867f04b30489968a2dcffce9faff4db4af6ae.tar.gz
Add prune_containers method
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/api/container.py')
-rw-r--r--docker/api/container.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/docker/api/container.py b/docker/api/container.py
index 6a764fb..9fa6d76 100644
--- a/docker/api/container.py
+++ b/docker/api/container.py
@@ -911,9 +911,6 @@ class ContainerApiMixin(object):
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
-
- Raises:
- :py:class:`~docker.errors.APIError` If an error occurs.
"""
params = {'path': path}
url = self._url('/containers/{0}/archive', container)
@@ -921,6 +918,28 @@ class ContainerApiMixin(object):
self._raise_for_status(res)
return res.status_code == 200
+ @utils.minimum_version('1.25')
+ def prune_containers(self, filters=None):
+ """
+ Delete stopped containers
+
+ Args:
+ filters (dict): Filters to process on the prune list.
+
+ Returns:
+ (dict): A dict containing a list of deleted container IDs and
+ the amount of disk space reclaimed in bytes.
+
+ Raises:
+ :py:class:`docker.errors.APIError`
+ If the server returns an error.
+ """
+ params = {}
+ if filters:
+ params['filters'] = utils.convert_filters(filters)
+ url = self._url('/containers/prune')
+ return self._result(self._post(url, params=params), True)
+
@utils.check_resource
def remove_container(self, container, v=False, link=False, force=False):
"""