avoid breaking if AutoRemove is not found

This commit is contained in:
root 2018-03-30 14:59:39 +01:00 committed by Erik Johnson
parent 97779c965d
commit a9f26f2ab8
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F

View file

@ -3048,7 +3048,14 @@ def rm_(name, force=False, volumes=False, **kwargs):
'remove this container'.format(name)
)
if stop_ and not force:
auto_remove = inspect_container(name)['HostConfig']['AutoRemove']
inspect_results = inspect_container(name)
try:
auto_remove = inspect_results['HostConfig']['AutoRemove']
except KeyError:
log.error(
'Failed to find AutoRemove in inspect results, Docker API may '
'have changed. Full results: %s', inspect_results
)
stop(name)
pre = ps_(all=True)