Skip to content

Commit

Permalink
Improve message error when docker isn't running (microsoft#3816) (mic…
Browse files Browse the repository at this point in the history
…rosoft#4600)

Co-authored-by: Jack Gerrits <[email protected]>
  • Loading branch information
gziz and jackgerrits authored Dec 10, 2024
1 parent 871a83f commit 3e5e12b
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,21 @@ async def start(self) -> None:
import asyncio_atexit

import docker
from docker.errors import ImageNotFound
from docker.errors import DockerException, ImageNotFound
except ImportError as e:
raise RuntimeError(
"Missing dependecies for DockerCommandLineCodeExecutor. Please ensure the autogen-ext package was installed with the 'docker' extra."
) from e

# Start a container from the image, read to exec commands later
client = docker.from_env()
try:
client = docker.from_env()
except DockerException as e:
if "FileNotFoundError" in str(e):
raise RuntimeError("Failed to connect to Docker. Please ensure Docker is installed and running.") from e
raise
except Exception as e:
raise RuntimeError(f"Unexpected error while connecting to Docker: {str(e)}") from e

# Check if the image exists
try:
Expand Down

0 comments on commit 3e5e12b

Please sign in to comment.