Skip to content

Commit dfb5536

Browse files
committed
Improve error handling when Docker daemon is not running
1 parent 679bac0 commit dfb5536

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pytest-mqtt changelog
66
in progress
77
===========
88

9+
- Improve error handling when Docker daemon is not running. Thanks, @horta.
10+
911

1012
2023-03-15 0.2.0
1113
================

pytest_mqtt/mosquitto.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ def pull_image(self):
5555
docker_client.images.pull(image_name)
5656

5757
def run(self):
58+
docker_client = docker.from_env(version=self.docker_version)
59+
docker_url = docker_client.api.base_url
60+
try:
61+
docker_client.ping()
62+
except Exception:
63+
raise ConnectionError(f"Cannot connect to the Docker daemon at {docker_url}. Is the docker daemon running?")
5864
self.pull_image()
5965
return super(Mosquitto, self).run()
6066

0 commit comments

Comments
 (0)