From dab69af033cd9822c3d199bda0ba3795b2852001 Mon Sep 17 00:00:00 2001 From: Ahmed Allam Date: Fri, 14 Nov 2025 02:01:51 +0400 Subject: [PATCH] fix(runtime): correct DOCKER_HOST parsing for sandbox URL --- strix/runtime/docker_runtime.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/strix/runtime/docker_runtime.py b/strix/runtime/docker_runtime.py index 32cc625..63cb7a0 100644 --- a/strix/runtime/docker_runtime.py +++ b/strix/runtime/docker_runtime.py @@ -358,11 +358,7 @@ class DockerRuntime(AbstractRuntime): container = self.client.containers.get(container_id) container.reload() - host = "127.0.0.1" - if "DOCKER_HOST" in os.environ: - docker_host = os.environ["DOCKER_HOST"] - if "://" in docker_host: - host = docker_host.split("://")[1].split(":")[0] + host = self._resolve_docker_host() except NotFound: raise ValueError(f"Container {container_id} not found.") from None @@ -371,6 +367,20 @@ class DockerRuntime(AbstractRuntime): else: return f"http://{host}:{port}" + def _resolve_docker_host(self) -> str: + docker_host = os.getenv("DOCKER_HOST", "") + if not docker_host: + return "127.0.0.1" + + from urllib.parse import urlparse + + parsed = urlparse(docker_host) + + if parsed.scheme in ("tcp", "http", "https") and parsed.hostname: + return parsed.hostname + + return "127.0.0.1" + async def destroy_sandbox(self, container_id: str) -> None: logger.info("Destroying scan container %s", container_id) try: