From 178a99c23f9ecface2324249444c24440a3aaefe Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 10 Sep 2021 17:55:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20an=20error=20message=20if=20t?= =?UTF-8?q?he=20connection=20to=20the=20Docker=20daemon=20fails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/sophon/notebooks/docker.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/sophon/notebooks/docker.py b/backend/sophon/notebooks/docker.py index 2d04d48..de1aa63 100644 --- a/backend/sophon/notebooks/docker.py +++ b/backend/sophon/notebooks/docker.py @@ -2,13 +2,19 @@ import enum import logging import time +import docker.errors import docker.models.containers log = logging.getLogger(__name__) log.info("Connecting to Docker daemon...") -client: docker.DockerClient = docker.from_env() -log.info("Connection to Docker daemon successful!") +try: + client: docker.DockerClient = docker.from_env() +except docker.errors.DockerException as e: + log.fatal("Could not connect to the Docker daemon!") + raise +else: + log.info("Connection to Docker daemon successful!") class HealthState(enum.IntEnum):