Configuration File Location
By default, the server looks for configuration at~/.sandbox.toml. Override with:
Initialize Configuration
Generate a configuration file with examples:Server Configuration
Control the HTTP server settings:Options
| Key | Type | Default | Description |
|---|---|---|---|
host | string | "0.0.0.0" | Interface to bind. Use "127.0.0.1" for localhost only |
port | integer | 8080 | Port to listen on |
log_level | string | "INFO" | Python logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL |
api_key | string | null | API key for authentication. If empty, authentication is disabled |
Log Levels
- DEBUG: Detailed diagnostic information
- INFO: General informational messages
- WARNING: Warning messages for potential issues
- ERROR: Error messages for failures
- CRITICAL: Critical errors that may cause shutdown
API Authentication
Authentication is enforced only whenapi_key is set:
- Empty or missing: Middleware skips API key checks (for local/dev)
- Non-empty: All endpoints (except
/health,/docs,/redoc) requireOPEN-SANDBOX-API-KEYheader
Runtime Configuration
Select and configure the sandbox runtime backend:Options
| Key | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Runtime implementation: "docker" or "kubernetes" |
execd_image | string | Yes | Container image with execd binary for sandbox initialization |
Docker Runtime Configuration
Docker-specific settings:Options
| Key | Type | Default | Description |
|---|---|---|---|
network_mode | string | "host" | Network mode: "host" (shared network) or "bridge" (isolated) |
api_timeout | integer | 180 | Docker API timeout in seconds |
host_ip | string | null | Host IP/hostname for bridge-mode endpoints when server runs in a container |
drop_capabilities | array | [] | Linux capabilities to drop from containers |
no_new_privileges | boolean | false | Block privilege escalation in containers |
apparmor_profile | string | "" | AppArmor profile name (e.g., "docker-default") |
pids_limit | integer | null | Max processes per container. null = unlimited |
seccomp_profile | string | "" | Seccomp profile path. Empty = Docker default |
Network Mode Comparison
| Feature | Host Mode | Bridge Mode |
|---|---|---|
| Performance | Best | Good |
| Isolation | None | Full |
| Port conflicts | Yes | No |
| Multiple sandboxes | Limited | Unlimited |
| Network policies | No | Yes (with egress sidecar) |
Security Capabilities
Recommended capabilities to drop:AUDIT_WRITE: Prevent audit log manipulationMKNOD: Block device node creationNET_ADMIN: Disable network configurationNET_RAW: Prevent raw socket creationSYS_ADMIN: Block administrative operationsSYS_MODULE: Prevent kernel module loadingSYS_PTRACE: Disable process tracingSYS_TIME: Block system clock changesSYS_TTY_CONFIG: Prevent TTY configuration
Kubernetes Runtime Configuration
Kubernetes-specific settings:Options
| Key | Type | Default | Description |
|---|---|---|---|
kubeconfig_path | string | null | Path to kubeconfig. null = in-cluster config |
namespace | string | "opensandbox" | Namespace for sandbox workloads |
workload_provider | string | "batchsandbox" | Provider type: "batchsandbox" or "agent-sandbox" |
batchsandbox_template_file | string | null | Path to BatchSandbox template YAML |
informer_enabled | boolean | true | Enable watch-based cache (beta) |
informer_resync_seconds | integer | 300 | Full list refresh interval (beta) |
informer_watch_timeout_seconds | integer | 60 | Watch restart interval (beta) |
Informer Configuration (Beta)
Informers reduce API server load through watch-based caching:- Enabled by default: Set
informer_enabled = falseto disable - Resync interval: How often to perform full list refresh
- Watch timeout: How long before restarting watch connection
- Tune for your cluster: Adjust based on API rate limits
Egress Configuration
Configure egress sidecar for network policy enforcement:Options
| Key | Type | Required | Description |
|---|---|---|---|
image | string | Required when using networkPolicy | Egress sidecar container image |
Network Policy Requirements
- Only supported in Docker bridge mode
- Egress image must be configured
- Requests with
networkPolicyare rejected in host mode - Main container shares sidecar network namespace
- Main container drops
NET_ADMINcapability - Sidecar retains
NET_ADMINfor iptables management - IPv6 disabled in shared namespace
Ingress Configuration
Control how clients access sandbox endpoints:Options
| Key | Type | Default | Description |
|---|---|---|---|
mode | string | "direct" | Ingress mode: "direct" or "gateway" |
gateway.address | string | null | Gateway address (domain, IP, or IP:port). No scheme. |
gateway.route.mode | string | "wildcard" | Routing mode: "wildcard", "uri", or "header" |
Ingress Modes
Direct Mode
Gateway Mode with Wildcard Routing
<sandbox-id>-<port>.example.com/path/to/request
Gateway Mode with URI Routing
10.0.0.1:8000/<sandbox-id>/<port>/path/to/request
Gateway Mode with Header Routing
gateway.example.com with header OpenSandbox-Ingress-To: <sandbox-id>-<port>
Storage Configuration
Control host path access for volume bind mounts:Options
| Key | Type | Default | Description |
|---|---|---|---|
allowed_host_paths | array | [] | Allowlist of host path prefixes for bind mounts |
Behavior
- Empty list: All host paths allowed (not recommended for production)
- Non-empty list: Only paths starting with listed prefixes are allowed
- Applies to volume bind mount requests
Agent-Sandbox Configuration
Configuration for agent-sandbox workload provider:Options
| Key | Type | Default | Description |
|---|---|---|---|
template_file | string | null | Sandbox CR YAML template path |
shutdown_policy | string | "Delete" | Shutdown policy: "Delete" or "Retain" |
ingress_enabled | boolean | true | Whether ingress routing is enabled |
Environment Variables
Override configuration with environment variables:| Variable | Description | Example |
|---|---|---|
SANDBOX_CONFIG_PATH | Override config file location | /etc/opensandbox/config.toml |
DOCKER_HOST | Docker daemon URL | unix:///var/run/docker.sock or ssh://user@host |
PENDING_FAILURE_TTL | TTL for failed pending sandboxes (seconds) | 3600 (default) |
Complete Configuration Examples
Production Docker Setup
Production Kubernetes Setup
Development Setup
Configuration Validation
The server validates configuration at startup:- Missing required fields:
runtime.typeandruntime.execd_imageare required - Invalid runtime type: Must be
"docker"or"kubernetes" - Network policy misconfiguration:
egress.imagerequired when usingnetworkPolicy - Invalid log level: Must be a valid Python logging level