{"record":{"id":"52b0f1ef2ceaba64","repo":"agentscope-ai/agentscope","slug":"failed-to-create-container-self-container-name-r","errorCode":null,"errorMessage":"Failed to create container {self._container_name!r}: stderr: {stderr.decode(errors='replace')}\\nstdout: {stdout.decode(errors='replace')}","messagePattern":"Failed to create container (.+?): stderr: (.+?)\\\\nstdout: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/workspace/_applecontainer/_applecontainer_workspace.py","lineNumber":484,"sourceCode":"            [\n                self.base_image,\n                \"sleep\",\n                \"infinity\",\n            ],\n        )\n\n        logger.info(\n            \"AppleContainerWorkspace: creating container %r ...\",\n            self._container_name,\n        )\n        process = await asyncio.create_subprocess_exec(\n            *run_cmd,\n            stdout=asyncio.subprocess.PIPE,\n            stderr=asyncio.subprocess.PIPE,\n        )\n        stdout, stderr = await process.communicate()\n        if process.returncode != 0:\n            raise RuntimeError(\n                f\"Failed to create container {self._container_name!r}: \"\n                f\"stderr: {stderr.decode(errors='replace')}\\n\"\n                f\"stdout: {stdout.decode(errors='replace')}\",\n            )\n        logger.info(\n            \"AppleContainerWorkspace: container %r created (id=%s)\",\n            self._container_name,\n            stdout.decode(errors=\"replace\").strip(),\n        )\n\n    # ── internals: bootstrap ────────────────────────────────────\n\n    def _bootstrap_commands(self) -> list[str]:\n        \"\"\"Shell commands that provision this container once.\n\n        Only runs when the gateway script is missing (fresh container\n        or prior interrupted bootstrap). Every step is idempotent.\n","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/workspace/_applecontainer/_applecontainer_workspace.py#L466-L502","documentation":"Raised when `container run -d` fails during _create_and_start_container, i.e. the Apple Containers CLI could not create the sandbox container. Includes both stderr and stdout of the failed command for diagnosis.","triggerScenarios":"Workspace initialization on a fresh environment where the container image is missing/not pulled, the container name is already taken, the runtime is unavailable, or `container run` rejects flags (image reference typo, unsupported macOS).","commonSituations":"First-run on a machine without the required container image, image registry unreachable, name collision with an existing container, Apple Container runtime not installed/enabled on the macOS version.","solutions":["Check stderr/stdout in the message for the exact CLI error","Verify the image exists locally: `container images` (pull it if missing)","Ensure the container name is not already in use: `container list`","Confirm the Apple Containers runtime is available and the macOS version is supported","Retry initialization after fixing the underlying CLI issue"],"exampleFix":"# before\nws = AppleContainerWorkspace(container_name=\"sand\", image=\"missing-img:latest\")\nawait ws.__aenter__()  # raises RuntimeError\n\n# after\n# verify/pull image first\n# container images  ->  container pull <image>\nws = AppleContainerWorkspace(container_name=\"sand\", image=\"example.com/img:tag\")\nawait ws.__aenter__()","handlingStrategy":"try-catch","validationCode":"import asyncio, shutil\nasync def image_available(image: str) -> bool:\n    if not shutil.which('container'):\n        return False\n    p = await asyncio.create_subprocess_exec('container', 'images')\n    out, _ = await p.communicate()\n    return image in out.decode()","typeGuard":null,"tryCatchPattern":"try:\n    async with AppleContainerWorkspace(...) as ws:\n        ...\nexcept RuntimeError as e:\n    # message contains the raw `container run` stderr/stdout\n    log.error('container create failed: %s', e)\n    raise","preventionTips":["Pre-pull the container image before first run","Use unique container names per session/workspace","Pin image tags that are known to work with your macOS version"],"tags":["applecontainer","container-create","image","macos","subprocess"],"backgroundTag":"container-create-failed","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}