@@ -833,7 +833,8 @@ def get(self, container_id):
833
833
resp = self .client .api .inspect_container (container_id )
834
834
return self .prepare_model (resp )
835
835
836
- def list (self , all = False , before = None , filters = None , limit = - 1 , since = None ):
836
+ def list (self , all = False , before = None , filters = None , limit = - 1 , since = None ,
837
+ sparse = False ):
837
838
"""
838
839
List containers. Similar to the ``docker ps`` command.
839
840
@@ -862,6 +863,9 @@ def list(self, all=False, before=None, filters=None, limit=-1, since=None):
862
863
container. Give the container name or id.
863
864
- `since` (str): Only containers created after a particular
864
865
container. Give container name or id.
866
+ sparse (bool): Do not inspect containers. Returns partial
867
+ informations, but guaranteed not to block. Use reload() on
868
+ each container to get the full list of attributes.
865
869
866
870
A comprehensive list can be found in the documentation for
867
871
`docker ps
@@ -877,7 +881,10 @@ def list(self, all=False, before=None, filters=None, limit=-1, since=None):
877
881
resp = self .client .api .containers (all = all , before = before ,
878
882
filters = filters , limit = limit ,
879
883
since = since )
880
- return [self .get (r ['Id' ]) for r in resp ]
884
+ if sparse :
885
+ return [self .prepare_model (r ) for r in resp ]
886
+ else :
887
+ return [self .get (r ['Id' ]) for r in resp ]
881
888
882
889
def prune (self , filters = None ):
883
890
return self .client .api .prune_containers (filters = filters )
0 commit comments