[modules/docker] Exception when daemon is not running

When the docker daemon is not running, only the call to
containers.list() actually throws an exception, so move that into the
exception guard.

fixes #608
This commit is contained in:
tobi-wan-kenobi 2020-04-30 20:13:23 +02:00
parent 88e56c4c47
commit a8e01f0df9

View file

@ -33,11 +33,11 @@ class Module(core.module.Module):
try:
cli = docker.DockerClient(base_url='unix://var/run/docker.sock')
cli.ping()
self.__info = 'OK - {}'.format(len(cli.containers.list(filters={'status': 'running'})))
except ConnectionError:
self.__info = 'daemon off'
except Exception:
self.__info = 'n/a'
self.__info = 'OK - {}'.format(len(cli.containers.list(filters={'status': 'running'})))
return self.__info
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4