FoundationAgents/OpenManus · error · RuntimeError
Failed to create sandbox: {e}
Error message
Failed to create sandbox: {e} What it means
Raised by DockerSandbox.create (app/sandbox/core/sandbox.py:103) when any step of sandbox bring-up throws: container creation, volume binding preparation, or AsyncDockerizedTerminal init. On failure it awaits self.cleanup() to release the half-created container, then raises RuntimeError chained (`from e`) to the original exception. This is the inner exception that manager.create_sandbox wraps into error 23.
Source
Thrown at app/sandbox/core/sandbox.py:103
self.container = self.client.containers.get(container["Id"])
# Start container
await asyncio.to_thread(self.container.start)
# Initialize terminal
self.terminal = AsyncDockerizedTerminal(
container["Id"],
self.config.work_dir,
env_vars={"PYTHONUNBUFFERED": "1"}
# Ensure Python output is not buffered
)
await self.terminal.init()
return self
except Exception as e:
await self.cleanup() # Ensure resources are cleaned up
raise RuntimeError(f"Failed to create sandbox: {e}") from e
def _prepare_volume_bindings(self) -> Dict[str, Dict[str, str]]:
"""Prepares volume binding configuration.
Returns:
Volume binding configuration dictionary.
"""
bindings = {}
# Create and add working directory mapping
work_dir = self._ensure_host_dir(self.config.work_dir)
bindings[work_dir] = {"bind": self.config.work_dir, "mode": "rw"}
# Add custom volume bindings
for host_path, container_path in self.volume_bindings.items():
bindings[host_path] = {"bind": container_path, "mode": "rw"}
return bindingsView on GitHub (pinned to 52a13f2a57)
Solutions
- Look at __cause__ of this RuntimeError — it is the original docker/terminal error.
- Test the same container manually: docker run -v <workdir>:<workdir> <image> sh.
- Ensure the host work_dir exists and is writable; ensure the image has a shell.
- Match docker library API version to the daemon (DowngradeAPI/upgrade issues).
Defensive patterns
Strategy: try-catch
Try / catch
try:
sandbox = await DockerSandbox(config).create()
except RuntimeError as e:
cause = e.__cause__ # original docker / terminal error
log.error("create failed: %r", cause)
raise Prevention
- Test the image manually with the same volume flags
- Ensure host work_dir is writable and the image has a shell
- Keep the docker library API version compatible with the daemon
- Never reuse a sandbox object after create() raised — cleanup already ran
When it happens
Trigger: Container start fails due to invalid config (bad image, conflicting volume binds, unsupported options); container['Id'] fetch succeeds but exec session for the terminal fails; cleanup path itself errors; work_dir host dir cannot be created (permissions).
Common situations: Non-writable host path for the work_dir volume; image lacks /bin/sh so exec fails; Docker API version mismatch between client library and daemon; SELinux/AppArmor denying the bind mount.
Related errors
- Session not initialized
- Terminal not initialized
- Maximum number of sandboxes ({self.max_sandboxes}) reached
- Failed to create sandbox: {e}
- Sandbox not initialized
AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15).
Data as JSON: /api/errors/3a96f30e6d4cd0ea.
Report an issue: GitHub.