catch run errors

This commit is contained in:
Gilles Grandou 2021-04-30 11:32:39 +02:00
parent c4e984a709
commit f546ca8817
1 changed files with 6 additions and 2 deletions

8
runon
View File

@ -125,8 +125,12 @@ def create_container(client, image, conf, command, verbose):
def run_container(client, container): def run_container(client, container):
dockerpty.start(client.api, container.id) try:
container.reload() # to update attrs fields dockerpty.start(client.api, container.id)
container.reload() # to update attrs fields
except docker.errors.APIError as e:
print('ERROR: {}'.format(e))
sys.exit(1)
ret = container.attrs['State']['ExitCode'] ret = container.attrs['State']['ExitCode']
return ret return ret