FoundationAgents/OpenManus · error · RuntimeError

Failed to create sandbox: {e}

Error message

Failed to create sandbox: {e}

What it means

Catch-all failure of SandboxManager.create_sandbox (app/sandbox/core/manager.py:157): any exception raised while constructing DockerSandbox or running sandbox.create() is logged, the partially registered sandbox is deleted via delete_sandbox to avoid a leak, and a RuntimeError wrapping the original message is re-raised. The original cause is in {e} — read it, not this wrapper.

Source

Thrown at app/sandbox/core/manager.py:157

                raise RuntimeError(f"Failed to ensure Docker image: {config.image}")

            sandbox_id = str(uuid.uuid4())
            try:
                sandbox = DockerSandbox(config, volume_bindings)
                await sandbox.create()

                self._sandboxes[sandbox_id] = sandbox
                self._last_used[sandbox_id] = asyncio.get_event_loop().time()
                self._locks[sandbox_id] = asyncio.Lock()

                logger.info(f"Created sandbox {sandbox_id}")
                return sandbox_id

            except Exception as e:
                logger.error(f"Failed to create sandbox: {e}")
                if sandbox_id in self._sandboxes:
                    await self.delete_sandbox(sandbox_id)
                raise RuntimeError(f"Failed to create sandbox: {e}")

    async def get_sandbox(self, sandbox_id: str) -> DockerSandbox:
        """Gets a sandbox instance.

        Args:
            sandbox_id: Sandbox ID.

        Returns:
            DockerSandbox: Sandbox instance.

        Raises:
            KeyError: If sandbox does not exist.
        """
        async with self.sandbox_operation(sandbox_id) as sandbox:
            return sandbox

    def start_cleanup_task(self) -> None:
        """Starts automatic cleanup task."""

View on GitHub (pinned to 52a13f2a57)

Solutions

  1. Inspect the {e} text — it carries the underlying docker error (port conflict, volume error, OCI runtime error).
  2. Check `docker ps -a` and `docker events` around the failure for the container-level cause.
  3. Validate volume_bindings host paths exist and are writable before creating.
  4. Free Docker resources (prune stopped containers/networks) and retry.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    sid = await manager.create_sandbox(config, volume_bindings)
except RuntimeError as e:
    log.error("sandbox create failed: %s", e.__cause__ or e)
    raise  # manager already cleaned up the partial sandbox

Prevention

When it happens

Trigger: docker.containers.run failing (name/port/volume conflict, image removed concurrently, resource exhaustion like out-of-memory or no available IP in the docker network); terminal exec creation failing inside sandbox.create(); invalid volume_bindings pointing at non-existent host dirs.

Common situations: Two sandboxes binding the same host port; host directory for a volume binding not created; Docker daemon out of resources after many sandboxes; leftover containers with a generated name colliding.

Related errors


AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15). Data as JSON: /api/errors/48fd07835b7e8387. Report an issue: GitHub.