Skip to main content

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

Sandbox Configuration

Resource Allocation

Sandboxes support configurable resource quotas:

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
By default, sandboxes have network access. Use network_block_all=True for maximum isolation when running untrusted code.

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

  1. Resource Allocation: Start with conservative resource quotas and scale up as needed
  2. Network Isolation: Always use network_block_all=True when running untrusted code
  3. Cleanup: Use auto-delete intervals to prevent resource waste
  4. Snapshots: Create snapshots of configured environments for faster startup
  5. Labels: Tag sandboxes with metadata for organization and cost tracking
  6. 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