diff options
author | Joffrey F <joffrey@docker.com> | 2018-04-25 16:55:40 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-04-25 17:00:26 -0700 |
commit | 1c903961b0d563eb05132800d3f42fb9fcbe4b32 (patch) | |
tree | 40edfad07f84f6f2cc362db3342313c068498d38 /docker/models/containers.py | |
parent | 0a5eda5799ecec995cbbd1c5b6ce4d9e571c3154 (diff) | |
download | docker-py-BenDoan-master.tar.gz |
Add ignore_removed param to containers.list() to control whether toBenDoan-master
raise or ignore NotFound
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/models/containers.py')
-rw-r--r-- | docker/models/containers.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/docker/models/containers.py b/docker/models/containers.py index 789fa93..b33a718 100644 --- a/docker/models/containers.py +++ b/docker/models/containers.py @@ -844,7 +844,7 @@ class ContainerCollection(Collection): return self.prepare_model(resp) def list(self, all=False, before=None, filters=None, limit=-1, since=None, - sparse=False): + sparse=False, ignore_removed=False): """ List containers. Similar to the ``docker ps`` command. @@ -882,6 +882,10 @@ class ContainerCollection(Collection): information, but guaranteed not to block. Use :py:meth:`Container.reload` on resulting objects to retrieve all attributes. Default: ``False`` + ignore_removed (bool): Ignore failures due to missing containers + when attempting to inspect containers from the original list. + Set to ``True`` if race conditions are likely. Has no effect + if ``sparse=True``. Default: ``False`` Returns: (list of :py:class:`Container`) @@ -902,7 +906,8 @@ class ContainerCollection(Collection): containers.append(self.get(r['Id'])) # a container may have been removed while iterating except NotFound: - pass + if not ignore_removed: + raise return containers def prune(self, filters=None): |