Improve Docker client connection

This commit is contained in:
nicolargo 2021-05-27 09:39:04 +02:00
parent 7275143318
commit b0dce2c6a1
1 changed files with 4 additions and 3 deletions

View File

@ -137,7 +137,8 @@ class Plugin(GlancesPlugin):
def connect(self):
"""Connect to the Docker server."""
try:
ret = docker.from_env(timeout=int(self.get_conf_value('timeout', '1')))
ret = docker.from_env(timeout=int(self.get_conf_value('timeout',
default='1')))
except Exception as e:
logger.error("docker plugin - Can not connect to Docker ({})".format(e))
ret = None
@ -164,8 +165,8 @@ class Plugin(GlancesPlugin):
# Init new stats
stats = self.get_init_value()
# The Docker-py lib is mandatory
if import_error_tag:
# The Docker-py lib is mandatory and connection should be ok
if import_error_tag or self.docker_client is None:
return self.stats
if self.input_method == 'local':