summaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rw-r--r--docker/api/container.py25
-rw-r--r--docker/models/containers.py17
2 files changed, 39 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):
"""
diff --git a/docker/models/containers.py b/docker/models/containers.py
index c4a4add..134db4e 100644
--- a/docker/models/containers.py
+++ b/docker/models/containers.py
@@ -763,6 +763,23 @@ class ContainerCollection(Collection):
since=since)
return [self.get(r['Id']) for r in resp]
+ def prune(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.
+ """
+ return self.client.api.prune_containers(filters=filters)
+
# kwargs to copy straight from run to create
RUN_CREATE_KWARGS = [