Networking in OpenSandbox is designed around one core idea: each sandbox is an independent security domain. Inbound traffic should only reach a sandbox through an authenticated, controlled path — never directly via raw IP. Outbound traffic should only reach explicitly allowed destinations. This document explains how these goals are achieved in single-host Docker deployments, in Kubernetes clusters, and through the per-sandbox egress sidecar that enforces outbound policy regardless of the underlying runtime.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/opensandbox-group/OpenSandbox/llms.txt
Use this file to discover all available pages before exploring further.
Single-Host (Docker) Networking
When the Docker runtime is configured, the OpenSandbox server manages all port routing for sandboxes running on a single host. Theexecd reverse proxy is the key mechanism that makes this efficient.
How bridge mode works
In the defaultbridge network mode, each sandbox container is placed on an isolated Docker bridge network. The Docker runtime maps only one host port per sandbox — the execd proxy port (44772). No other container ports need to be published.
- External traffic hits
{host_ip}:{host_proxy_port}— the single published host port for this sandbox. - Docker forwards the request to
execdinside the container on port44772. execdextracts the target port from the/proxy/{port}path prefix and forwards the request to127.0.0.1:{port}inside the same container.- The response flows back through the same path.
execd preserves Upgrade, Connection, and related HTTP headers, this single proxy port handles HTTP, Server-Sent Events (SSE), and WebSocket traffic without any additional configuration.
Endpoint resolution:
Port 8080 direct mapping
In addition to the proxy port, port 8080 may receive a direct host binding (labeled opensandbox.io/http-port) for applications that need a conventional HTTP endpoint without the /proxy/ path prefix.
Host network mode
Innetwork_mode = "host", the sandbox container shares the host network stack. Each container port is directly accessible on the host — no proxy is needed. get_endpoint(port=X) returns {host_ip}:{X} directly.
Internal access shortcut
When the server itself runs inside a Docker container (e.g., via Docker Compose), callers on the same Docker network can bypass the host port mapping:Kubernetes Networking
Kubernetes deployments use the OpenSandbox ingress gateway to route external traffic to sandbox pods. This provides a single, authenticated entry point that avoids exposing raw pod IPs.Ingress gateway routing
The ingress component (components/ingress/) is an HTTP/WebSocket reverse proxy that watches BatchSandbox and AgentSandbox CRs across all namespaces. It discovers sandbox endpoints from the sandbox.opensandbox.io/endpoints annotation (BatchSandbox) or status.serviceFQDN (AgentSandbox) and routes incoming requests accordingly.
Two routing strategies are supported:
- Header mode
- URI mode
Routes based on the Header mode is the default and is well-suited for server-side SDK and API clients that can set custom headers.
OpenSandbox-Ingress-To: <sandbox-id>-<port> request header or the Host: <sandbox-id>-<port>.<domain> header.Secure access
WhensecureAccess is enabled for a Kubernetes sandbox, the server provisions endpoint credentials and returns required headers with endpoint responses. This ensures that even if an ingress endpoint is publicly reachable, only authenticated callers can reach the sandbox.
Components deployed on Kubernetes
| Component | Deployment | Network role |
|---|---|---|
| Server | Deployment | Receives SDK/API calls; provisions sandboxes |
| Ingress | DaemonSet or Deployment | Routes external HTTP/WS traffic to sandbox pods |
| Egress sidecar | Per-pod | Enforces outbound policy from inside each sandbox’s network namespace |
| Execd | Init container → sandbox pod | Exposes in-sandbox execution API |
Egress Isolation
Every sandbox that is created with anetworkPolicy gets an egress sidecar that runs inside the sandbox’s network namespace and enforces outbound traffic policy.
How the sidecar works
- DNS proxy (Layer 1) — intercepts all DNS traffic via
iptablesredirect and filters queries against the FQDN allowlist. Denied domains receiveNXDOMAIN. - nftables (Layer 2,
dns+nftmode) — enforces IP-level allow/deny. When a domain is resolved and allowed, its A/AAAA records are added to a dynamic nftables set with TTL. All other outbound IPs are dropped.
Default-deny with FQDN allowlist
Platform-enforced isolation (deny.always)
For multi-tenant Kubernetes deployments, operators should bake cluster CIDRs into the egress sidecar image using adeny.always rule file. This blocks direct pod-to-pod and pod-to-service communication at the platform level, regardless of per-sandbox user policy.
- Sandboxes cannot reach other pods directly via Pod IP.
- Sandboxes cannot reach in-cluster Services via ClusterIP.
- Legitimate cross-sandbox communication must go through
get_endpoint(), which returns an authenticated ingress gateway URL. - Platform operators do not need to change individual sandbox creation requests — isolation is enforced automatically.
deny.always rules are hot-reloaded every minute. To update after a cluster CIDR change, rebuild the image with the new rule file and perform a rolling update of the server egress configuration.Allowing in-cluster Kubernetes services
WhendefaultAction: deny is set, allowing a sandbox to reach a Kubernetes Service requires both DNS and network allowances in dns+nft mode:
Rule precedence
networkPolicy at sandbox creation time.
Runtime policy mutation
Egress policy can be inspected and updated at runtime without restarting the sandbox. Resolve the egress endpoint and call the HTTP API:Egress and Service Mesh Compatibility
The egress sidecar installsiptables/nft redirect rules in the shared pod network namespace. Transparent service meshes such as Istio/Envoy also redirect outbound traffic in that same namespace. When both are present, the redirect order is undefined and can produce double interception, broken TLS, or traffic that bypasses the egress policy path.
Recommended operator choices:
- Exclude sandbox pods from automatic mesh sidecar injection when they need the egress sidecar.
- If mesh injection is mandatory, use a platform-level CNI/network-policy mechanism for outbound control instead of the OpenSandbox egress sidecar.
Secure Container Runtime Isolation
Beyond network-level isolation, OpenSandbox supports kernel-level sandbox isolation via secure container runtimes. These runtimes replace the standardrunc container runtime with a stronger isolation boundary.
| Runtime | Isolation mechanism | Docker | Kubernetes | Egress sidecar |
|---|---|---|---|---|
gVisor (runsc) | User-space kernel (Go) | ✅ | ✅ | ⚠️ Not compatible (no iptables nat table) |
Kata Containers (kata-qemu) | Hardware VM | ✅ | ✅ | ✅ Supported |
Kata Firecracker (kata-fc) | microVM | — | ✅ | ✅ Supported |
[secure_runtime]:
RuntimeClass resource. Pass secureRuntime: true in the sandbox creation request to opt in. See the Secure Container guide for the complete compatibility matrix and setup instructions.
Related
- Architecture Overview — Six-surface architecture and request flow
- Components — Ingress and egress component reference
- Docker Deployment — Single-host networking setup
- Kubernetes Deployment — Kubernetes ingress and operator setup
- Secure Container — gVisor, Kata, and Firecracker configuration
- Credential Vault — Automatic credential injection via the egress sidecar