Prerequisites
Before deploying with Docker runtime, ensure you have:- Docker Engine 20.10+ installed and running
- Python 3.10+ for the OpenSandbox server
- uv package manager (recommended) or pip
- Operating System: Linux, macOS, or Windows with WSL2
Installation
Install OpenSandbox Server
Install the server package from PyPI:For source development, clone the repository and run
uv sync inside server/.Initialize Configuration
Generate a Docker configuration file:This creates a basic Docker runtime configuration at
~/.sandbox.toml.Configure Runtime Settings
Edit
~/.sandbox.toml to customize your deployment. See Configuration Options below.Start the Server
Launch the server with your configuration:The server will start at
http://0.0.0.0:8080 by default.Configuration Options
Basic Docker Configuration
Minimal configuration for Docker runtime:Network Modes
Docker runtime supports two networking modes:Host Mode
Containers share the host network stack for maximum performance:- Direct port access without NAT
- Best performance
- Only one sandbox per port
- Endpoint format:
http://{domain}/{sandbox_id}/{port}
Bridge Mode
Isolated container networking with HTTP routing:- Network isolation between containers
- Multiple sandboxes can use the same port
- Built-in HTTP routing support
- Endpoint format varies by ingress configuration
Security Hardening
Apply security controls to Docker containers:Network Policy with Egress Sidecar
Control outbound network traffic with egress policies:- Only supported in bridge mode
- Egress image must be configured when using
networkPolicy - Automatically disabled for host mode
Advanced Docker Settings
Ingress Configuration
Configure how clients access sandboxes:Direct Mode (Default)
Gateway Mode
- Wildcard:
<sandbox-id>-<port>.example.com/path/to/request - URI:
10.0.0.1:8000/<sandbox-id>/<port>/path/to/request - Header:
gateway.example.comwith headerOpenSandbox-Ingress-To: <sandbox-id>-<port>
Storage Configuration
Control host path access for bind mounts:Environment Variables
Override configuration with environment variables:| Variable | Description |
|---|---|
SANDBOX_CONFIG_PATH | Override config file location |
DOCKER_HOST | Docker daemon URL (e.g., unix:///var/run/docker.sock) |
PENDING_FAILURE_TTL | TTL for failed pending sandboxes in seconds (default: 3600) |
Example: Create a Sandbox
Once the server is running, create a sandbox:Troubleshooting
Server Won’t Start
- Verify Docker daemon is running:
docker ps - Check configuration syntax:
opensandbox-server init-config ~/.sandbox.toml - Enable debug logging:
log_level = "DEBUG"
Connection Refused
- Check
DOCKER_HOSTenvironment variable - Verify Docker socket permissions
- Use remote Docker:
export DOCKER_HOST="ssh://user@remote-host"
Network Policy Not Working
- Ensure
network_mode = "bridge" - Verify
egress.imageis configured - Check that egress image is accessible