From af94679897b8e79ffd5c8bceeaf2d422922be421 Mon Sep 17 00:00:00 2001 From: Daniel Sola Date: Tue, 19 Nov 2024 17:39:41 -0800 Subject: [PATCH] add error message when docker isn't running Signed-off-by: Daniel Sola --- flytekit/image_spec/image_spec.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/flytekit/image_spec/image_spec.py b/flytekit/image_spec/image_spec.py index 5af5a5c2de..1b7c4791bf 100644 --- a/flytekit/image_spec/image_spec.py +++ b/flytekit/image_spec/image_spec.py @@ -227,7 +227,7 @@ def exist(self) -> Optional[bool]: Return None if failed to check if the image exists due to the permission issue or other reasons. """ import docker - from docker.errors import APIError, ImageNotFound + from docker.errors import APIError, DockerException, ImageNotFound try: client = docker.from_env() @@ -278,6 +278,16 @@ def exist(self) -> Optional[bool]: f" pip install --upgrade docker" ) + if isinstance(e, DockerException) and "Error while fetching server API version" in str(e): + click.secho( + "Unable to connect to Docker daemon. Please ensure Docker is installed and running.\n" + "You can start Docker by:\n" + " - Windows/Mac: Start the Docker Desktop application\n" + " - Linux: Run 'sudo systemctl start docker'", + fg="red", + ) + return None + click.secho(f"Failed to check if the image exists with error:\n {e}", fg="red") return None