summaryrefslogtreecommitdiff
path: root/compose/container.py
diff options
context:
space:
mode:
authorAanand Prasad <aanand.prasad@gmail.com>2015-08-10 16:00:45 +0100
committerAanand Prasad <aanand.prasad@gmail.com>2015-08-10 16:29:12 +0100
commitdfa4bf4452584f1a2533254231b862d521d75f85 (patch)
tree7b745d5a5c6de27746fe531c1fc4c2ae32255410 /compose/container.py
parent6cb8e512f211696d6c1ba5482606d791eaf302a3 (diff)
Ignore containers that don't have a name
If a container is in the process of being removed, or removal has failed, it can sometimes appear in the output of GET /containers/json but not have a 'Name' key. In that case, rather than crashing, we can ignore it. Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
Diffstat (limited to 'compose/container.py')
-rw-r--r--compose/container.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/compose/container.py b/compose/container.py
index 71951497..40aea98a 100644
--- a/compose/container.py
+++ b/compose/container.py
@@ -22,10 +22,14 @@ class Container(object):
"""
Construct a container object from the output of GET /containers/json.
"""
+ name = get_container_name(dictionary)
+ if name is None:
+ return None
+
new_dictionary = {
'Id': dictionary['Id'],
'Image': dictionary['Image'],
- 'Name': '/' + get_container_name(dictionary),
+ 'Name': '/' + name,
}
return cls(client, new_dictionary, **kwargs)