From 85261ec688b81c8bc750fb6c9c956d1048a5148c Mon Sep 17 00:00:00 2001 From: JP Cottin Date: Thu, 14 May 2026 20:31:08 -0700 Subject: [PATCH] Honor DOCKER_HOST in get_api_client() The docker-py SDK's APIClient() constructor does not read DOCKER_HOST; only from_env() does. Without it, emu-docker silently ignores the env var and falls back to /var/run/docker.sock, which fails on Docker Desktop, podman, and anyone whose daemon socket is elsewhere with: DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied')) Pass base_url=os.environ.get("DOCKER_HOST") so the standard env var contract works. Also corrects the malformed fallback URI unix://var/run/docker.sock to the canonical unix:///var/run/docker.sock. --- emu/containers/docker_container.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/emu/containers/docker_container.py b/emu/containers/docker_container.py index e01da83..f51bd80 100644 --- a/emu/containers/docker_container.py +++ b/emu/containers/docker_container.py @@ -33,8 +33,10 @@ def get_client(self) -> docker.DockerClient: return docker.from_env() def get_api_client(self) -> docker.APIClient: + # Honor DOCKER_HOST so Docker Desktop, podman, and other rootless or + # non-default daemon sockets work without symlinking /var/run/docker.sock. try: - api_client = docker.APIClient() + api_client = docker.APIClient(base_url=os.environ.get("DOCKER_HOST")) logging.info(api_client.version()) return api_client except Exception as _err: @@ -42,7 +44,7 @@ def get_api_client(self) -> docker.APIClient: "Failed to create default client, trying domain socket.", exc_info=True ) - api_client = docker.APIClient(base_url="unix://var/run/docker.sock") + api_client = docker.APIClient(base_url="unix:///var/run/docker.sock") logging.info(api_client.version()) return api_client