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>
This commit is contained in:
parent
6cb8e512f2
commit
dfa4bf4452
6 changed files with 64 additions and 11 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue