summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Nottale <matthieu.nottale@docker.com>2018-03-14 15:30:30 +0100
committerJoffrey F <f.joffrey@gmail.com>2018-03-29 16:25:14 -0700
commit726d7f31cabebbd545337733a38b79bf36d2846b (patch)
tree50280300b9bf7414c2588d62ccd58b3691b7c492
parent35520ab01fc49052f1ccf145933e89a8c368a364 (diff)
downloaddocker-py-726d7f31cabebbd545337733a38b79bf36d2846b.tar.gz
Add sparse argument to DockerClient.containers.list().
Signed-off-by: Matthieu Nottale <matthieu.nottale@docker.com>
-rw-r--r--docker/models/containers.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/docker/models/containers.py b/docker/models/containers.py
index 895080c..d4ed1aa 100644
--- a/docker/models/containers.py
+++ b/docker/models/containers.py
@@ -833,7 +833,8 @@ class ContainerCollection(Collection):
resp = self.client.api.inspect_container(container_id)
return self.prepare_model(resp)
- def list(self, all=False, before=None, filters=None, limit=-1, since=None):
+ def list(self, all=False, before=None, filters=None, limit=-1, since=None,
+ sparse=False):
"""
List containers. Similar to the ``docker ps`` command.
@@ -862,6 +863,9 @@ class ContainerCollection(Collection):
container. Give the container name or id.
- `since` (str): Only containers created after a particular
container. Give container name or id.
+ sparse (bool): Do not inspect containers. Returns partial
+ informations, but guaranteed not to block. Use reload() on
+ each container to get the full list of attributes.
A comprehensive list can be found in the documentation for
`docker ps
@@ -877,7 +881,10 @@ class ContainerCollection(Collection):
resp = self.client.api.containers(all=all, before=before,
filters=filters, limit=limit,
since=since)
- return [self.get(r['Id']) for r in resp]
+ if sparse:
+ return [self.prepare_model(r) for r in resp]
+ else:
+ return [self.get(r['Id']) for r in resp]
def prune(self, filters=None):
return self.client.api.prune_containers(filters=filters)