From b6d7e222c1f6dad4c4929b7610e8614c3b6828c2 Mon Sep 17 00:00:00 2001 From: Raeli Savitt Date: Wed, 25 Feb 2026 22:31:05 -0500 Subject: [PATCH] Fix Docker backend failures on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three issues prevented the Docker terminal backend from working: 1. `effective_image` was referenced but never defined — only the Modal backend sets this variable. Use `image` directly instead. 2. `--storage-opt size=N` is unsupported on Docker Desktop for Mac (requires overlay2 with xfs backing). Skip the flag on Darwin. 3. Docker requires absolute paths for `-w` (working directory) but the default cwd was `~`, which Docker does not expand. Default to `/root` and translate any `~` passed in from callers. Co-Authored-By: Claude Opus 4.6 --- tools/environments/docker.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/environments/docker.py b/tools/environments/docker.py index c839f9b8..aef63e5f 100644 --- a/tools/environments/docker.py +++ b/tools/environments/docker.py @@ -7,6 +7,7 @@ and optional filesystem persistence via `docker commit`/`docker create --image`. import logging import os import subprocess +import sys import threading import time from typing import Optional @@ -44,7 +45,7 @@ class DockerEnvironment(BaseEnvironment): def __init__( self, image: str, - cwd: str = "~", + cwd: str = "/root", timeout: int = 60, cpu: float = 0, memory: int = 0, @@ -53,6 +54,8 @@ class DockerEnvironment(BaseEnvironment): task_id: str = "default", network: bool = True, ): + if cwd == "~": + cwd = "/root" super().__init__(cwd=cwd, timeout=timeout) self._base_image = image self._persistent = persistent_filesystem @@ -67,7 +70,7 @@ class DockerEnvironment(BaseEnvironment): resource_args.extend(["--cpus", str(cpu)]) if memory > 0: resource_args.extend(["--memory", f"{memory}m"]) - if disk > 0: + if disk > 0 and sys.platform != "darwin": resource_args.extend(["--storage-opt", f"size={disk}m"]) if not network: resource_args.append("--network=none") @@ -102,7 +105,7 @@ class DockerEnvironment(BaseEnvironment): all_run_args = list(_SECURITY_ARGS) + writable_args + resource_args self._inner = _Docker( - image=effective_image, cwd=cwd, timeout=timeout, + image=image, cwd=cwd, timeout=timeout, run_args=all_run_args, ) self._container_id = self._inner.container_id