Overview
Sandboxes are the core primitive in Daytona - isolated, containerized execution environments where AI-generated code runs securely. Each sandbox provides a complete development environment with its own filesystem, process space, and network isolation.What is a Sandbox?
A Daytona Sandbox is a lightweight, isolated container instance that provides:- Complete Isolation: Separate filesystem, process space, and network namespace
- Resource Allocation: Configurable CPU, memory, GPU, and disk quotas
- Persistent State: Sandboxes can be stopped and restarted without losing data
- Network Control: Granular network access policies and egress filtering
- OCI Compatibility: Built on any OCI/Docker image
Sandboxes are designed for sub-90ms creation time, enabling rapid iteration and massive parallelization for AI workflows.
Sandbox Lifecycle
Sandboxes transition through various states during their lifecycle:Sandbox States
All Sandbox States
All Sandbox States
| State | Description |
|---|---|
creating | Sandbox is being initialized |
pending_build | Waiting for snapshot build to begin |
building_snapshot | Building snapshot from source |
pulling_snapshot | Pulling snapshot image from registry |
started | Sandbox is running and ready |
stopped | Sandbox is stopped but preserved |
starting | Sandbox is being started |
stopping | Sandbox is being stopped |
archived | Sandbox is archived to storage |
restoring | Sandbox is being restored from archive |
resizing | Sandbox resources are being adjusted |
destroying | Sandbox is being deleted |
destroyed | Sandbox has been removed |
error | Sandbox encountered an error |
build_failed | Snapshot build failed |
unknown | Sandbox state is unknown |
Sandbox Configuration
Resource Allocation
Sandboxes support configurable resource quotas:- Python
- TypeScript
- Go
Network Configuration
Control network access with fine-grained policies:- Network Block All: Completely isolate the sandbox from external networks
- Network Allow List: Specify CIDR ranges for allowed network access
- Public HTTP Preview: Enable public access to sandbox HTTP ports
Environment Variables
Pass configuration and secrets via environment variables:Labels
Organize sandboxes with custom labels:Sandbox Automation
Auto-Stop
Automatically stop sandboxes after a period of inactivity:Auto-Archive
Archive stopped sandboxes to reduce costs:Auto-Delete
Automatically clean up sandboxes:Set
auto_delete_interval=0 to delete immediately upon stopping. Use -1 to disable auto-deletion.Sandbox Operations
Starting and Stopping
Resizing
Dynamically adjust sandbox resources:Deletion
Use Cases
AI Code Execution
Run AI-generated code in isolated environments:Development Environments
Create on-demand development workspaces:Testing and CI/CD
Run tests in isolated, reproducible environments:Agent Workspaces
Provide persistent workspaces for AI agents:Best Practices
- Resource Allocation: Start with conservative resource quotas and scale up as needed
- Network Isolation: Always use
network_block_all=Truewhen running untrusted code - Cleanup: Use auto-delete intervals to prevent resource waste
- Snapshots: Create snapshots of configured environments for faster startup
- Labels: Tag sandboxes with metadata for organization and cost tracking
- Volumes: Use volumes for persistent data that should survive sandbox deletion
Next Steps
Snapshots
Learn about creating and managing snapshots
Volumes
Understand persistent storage with volumes
Architecture
Explore Daytona’s system architecture
Security
Learn about isolation and security