Snapshots
Snapshots are reusable sandbox templates that provide a consistent and reproducible environment for your dependencies, settings, and resources.
A snapshot defines the base operating system, language runtimes, system packages, and project-level setup that should exist when a sandbox starts. Instead of repeating bootstrap steps on every sandbox creation, you capture that setup once as a snapshot and reuse it.
You start with default snapshots for common stacks, or create custom snapshots for your own toolchain and constraints. Custom snapshots are useful when your workflow depends on specific package versions, private dependencies, startup scripts, or filesystem layout. A snapshot created for one sandbox class cannot create a sandbox of the other class.
Default snapshots
Section titled “Default snapshots”Daytona provides default snapshots with fixed resource sizes for creating sandboxes.
| Snapshot | vCPU | Memory | Storage | GPU | Sandbox Class |
|---|---|---|---|---|---|
daytona-small | 1 | 1GiB | 3GiB | Container | |
daytona-medium | 2 | 4GiB | 8GiB | Container | |
daytona-large | 4 | 8GiB | 10GiB | Container | |
daytona-gpu | 1 | 1GiB | 1GiB | 1 | GPU |
daytona-vm-small | 1 | 1GiB | 3GiB | Linux VM | |
daytona-vm-medium | 2 | 4GiB | 8GiB | Linux VM | |
daytona-vm-large | 4 | 8GiB | 10GiB | Linux VM | |
windows-small | 1 | 4GiB | 30GiB | Windows | |
windows-medium | 2 | 8GiB | 50GiB | Windows | |
windows-large | 4 | 16GiB | 50GiB | Windows |
- Go to Daytona Sandboxes ↗
- Click Create Sandbox
- Select a
snapshot - Click Create
from daytona import Daytona, CreateSandboxFromSnapshotParams
daytona = Daytona()sandbox = daytona.create( CreateSandboxFromSnapshotParams( snapshot="daytona-small", ))import { Daytona } from '@daytona/sdk'
const daytona = new Daytona()const sandbox = await daytona.create({ snapshot: 'daytona-small',})require 'daytona'
daytona = Daytona::Daytona.newsandbox = daytona.create( Daytona::CreateSandboxFromSnapshotParams.new( snapshot: 'daytona-small' ))package main
import ( "context" "github.com/daytona/clients/sdk-go/pkg/daytona" "github.com/daytona/clients/sdk-go/pkg/types")
func main() { client, _ := daytona.NewClient() ctx := context.Background() params := types.SnapshotParams{ Snapshot: "daytona-small", } _, _ = client.Create(ctx, params)}import io.daytona.sdk.Daytona;import io.daytona.sdk.Sandbox;import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams(); params.setSnapshot("daytona-small"); Sandbox sandbox = daytona.create(params); } }}daytona create --snapshot daytona-smallcurl 'https://app.daytona.io/api/sandbox' \ --request POST \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_API_KEY' \ --data '{ "snapshot": "daytona-small"}'Default snapshots include pre-installed Python and Node.js packages.
| Package | Version |
|---|---|
anthropic | v0.76.0 |
beautifulsoup4 | v4.14.3 |
claude-agent-sdk | v0.1.22 |
openai-agents | v0.15.1 |
daytona | v0.134.0 |
django | v6.0.1 |
flask | v3.1.2 |
huggingface-hub | v0.36.0 |
instructor | v1.14.4 |
keras | v3.13.0 |
langchain | v1.2.7 |
llama-index | v0.14.13 |
matplotlib | v3.10.8 |
numpy | v2.4.1 |
ollama | v0.6.1 |
openai | v2.33.0 |
opencv-python | v4.13.0.90 |
pandas | v2.3.3 |
pillow | v12.1.0 |
pipx | v1.8.0 |
pydantic-ai | v1.47.0 |
python-lsp-server | v1.14.0 |
requests | v2.32.5 |
scikit-learn | v1.8.0 |
scipy | v1.17.0 |
seaborn | v0.13.2 |
sqlalchemy | v2.0.46 |
torch | v2.10.0 |
transformers | v4.57.6 |
uv | v0.9.26 |
| Package | Version |
|---|---|
@anthropic-ai/claude-code | v2.1.19 |
@openai/codex | v0.128.0 |
bun | v1.3.6 |
openclaw | v2026.2.1 |
opencode-ai | v1.1.35 |
ts-node | v10.9.2 |
typescript | v5.9.3 |
typescript-language-server | v5.1.3 |
Create snapshots
Section titled “Create snapshots”Create a snapshot.
-
Go to Daytona Snapshots ↗
-
Click Create Snapshot
-
Enter the snapshot
nameandimage- Snapshot name: identifier used to reference the snapshot
- Snapshot image: base image for the snapshot, must include either a tag or a digest (e.g.,
ubuntu:22.04); thelatest/lts/stabletags are not supported
-
Click Create
from daytona import Daytona, CreateSnapshotParams
daytona = Daytona()snapshot = daytona.snapshot.create( CreateSnapshotParams(name="my-awesome-snapshot", image="ubuntu:22.04"),)import { Daytona } from "@daytona/sdk";
const daytona = new Daytona();const snapshot = await daytona.snapshot.create({ name: "my-awesome-snapshot", image: "python:3.12",});require 'daytona'
daytona = Daytona::Daytona.newsnapshot = daytona.snapshot.create( Daytona::CreateSnapshotParams.new(name: 'my-awesome-snapshot', image: 'python:3.12'))package main
import ( "context"
"github.com/daytona/clients/sdk-go/pkg/daytona" "github.com/daytona/clients/sdk-go/pkg/types")
func main() { client, _ := daytona.NewClient() ctx := context.Background() snapshot, logCh, _ := client.Snapshot.Create(ctx, &types.CreateSnapshotParams{ Name: "my-awesome-snapshot", Image: "python:3.12", }) for range logCh { } _ = snapshot}import io.daytona.sdk.Daytona;import io.daytona.sdk.model.Snapshot;
final class CreateSnapshot { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { Snapshot snapshot = daytona.snapshot().create("my-awesome-snapshot", "python:3.12"); } }}daytona snapshot create my-awesome-snapshot --image python:3.11-slim --cpu 2 --memory 4curl https://app.daytona.io/api/snapshots \ --request POST \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \ --data '{ "name": "my-awesome-snapshot", "imageName": "python:3.11-slim", "cpu": 2, "memory": 4 }'GPU snapshots
Section titled “GPU snapshots”Create a GPU snapshot. GPU snapshots are used to create GPU sandboxes.
-
Go to Daytona Snapshots ↗
-
Click Create Snapshot
-
Enter the snapshot
nameandimage -
Select the
Allocate GPUcheckbox -
Specify the
GPU type(s):NVIDIA H100NVIDIA H200NVIDIA RTX PRO 6000NVIDIA RTX 4090NVIDIA RTX 5090
-
Click Create
from daytona import CreateSnapshotParams, Daytona, Image, Resources
daytona = Daytona()snapshot = daytona.snapshot.create( CreateSnapshotParams( name="my-gpu-snapshot", image=Image.base("python:3.12"), resources=Resources(cpu=1, memory=1, disk=1, gpu=1), ),)import { Daytona } from "@daytona/sdk";
const daytona = new Daytona();const snapshot = await daytona.snapshot.create({ name: "my-gpu-snapshot", image: "python:3.12", resources: { cpu: 1, memory: 1, disk: 1, gpu: 1 },});require 'daytona'
daytona = Daytona::Daytona.newsnapshot = daytona.snapshot.create( Daytona::CreateSnapshotParams.new( name: 'my-gpu-snapshot', image: 'python:3.12', resources: Daytona::Resources.new(cpu: 1, memory: 1, disk: 1, gpu: 1) ))package main
import ( "context" "github.com/daytona/clients/sdk-go/pkg/daytona" "github.com/daytona/clients/sdk-go/pkg/types")
func main() { client, _ := daytona.NewClient() ctx := context.Background() snapshot, logCh, _ := client.Snapshot.Create(ctx, &types.CreateSnapshotParams{ Name: "my-gpu-snapshot", Image: "python:3.12", Resources: &types.Resources{ CPU: 1, Memory: 1, Disk: 1, GPU: 1, }, }) for range logCh { } _ = snapshot}import io.daytona.sdk.Daytona;import io.daytona.sdk.Image;import io.daytona.sdk.model.Resources;import io.daytona.sdk.model.Snapshot;
final class CreateGpuSnapshot { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { Resources resources = new Resources(); resources.setCpu(1); resources.setMemory(1); resources.setDisk(1); resources.setGpu(1); Snapshot snapshot = daytona.snapshot().create( "my-gpu-snapshot", Image.base("python:3.12"), resources, null ); } }}curl https://app.daytona.io/api/snapshots \ --request POST \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \ --data '{ "name": "my-gpu-snapshot", "imageName": "python:3.12", "cpu": 1, "memory": 1, "disk": 1, "gpu": 1 }'VM snapshots
Section titled “VM snapshots”Daytona provides methods to create VM snapshots for Linux and Windows.
VM snapshots are used to create VM sandboxes. VM snapshots are distinct from container snapshots and cannot be used to create container sandboxes. VM snapshots support VM-only capabilities such as creating hot/cold snapshots from sandboxes.
Linux VM snapshots
Section titled “Linux VM snapshots”Create a Linux VM snapshot.
- Create a snapshot from a base
image - Set the snapshot’s sandbox class to
LINUX_VM
from daytona import Daytona, CreateSnapshotParams, SandboxClass
daytona = Daytona()snapshot = daytona.snapshot.create( CreateSnapshotParams( name="my-vm-snapshot", image="ubuntu:22.04", sandbox_class=SandboxClass.LINUX_VM, ))import { Daytona, SandboxClass } from "@daytona/sdk";
const daytona = new Daytona();const snapshot = await daytona.snapshot.create({ name: "my-vm-snapshot", image: "ubuntu:22.04", sandboxClass: SandboxClass.LINUX_VM,});require 'daytona'
daytona = Daytona::Daytona.newsnapshot = daytona.snapshot.create( Daytona::CreateSnapshotParams.new( name: 'my-vm-snapshot', image: 'ubuntu:22.04', sandbox_class: DaytonaApiClient::SandboxClass::LINUX_VM ))package main
import ( "context"
"github.com/daytona/clients/sdk-go/pkg/daytona" "github.com/daytona/clients/sdk-go/pkg/types")
func main() { client, _ := daytona.NewClient() ctx := context.Background()
sandboxClass := types.SandboxClassLinuxVM snapshot, logCh, _ := client.Snapshot.Create(ctx, &types.CreateSnapshotParams{ Name: "my-vm-snapshot", Image: "ubuntu:22.04", SandboxClass: &sandboxClass, }) for range logCh { } _ = snapshot}import io.daytona.sdk.Daytona;import io.daytona.api.client.model.SandboxClass;import io.daytona.sdk.model.Snapshot;
final class CreateVmSnapshot { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { Snapshot snapshot = daytona.snapshot().create("my-vm-snapshot", "ubuntu:22.04", SandboxClass.LINUX_VM); } }}daytona snapshot create my-vm-snapshot --image ubuntu:22.04 --sandbox-class linux-vmcurl https://app.daytona.io/api/snapshots \ --request POST \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \ --data '{ "name": "my-vm-snapshot", "imageName": "ubuntu:22.04", "sandboxClass": "linux-vm" }'Windows VM snapshots
Section titled “Windows VM snapshots”Windows VM snapshots are used to create Windows VM sandboxes. They cannot be created from a base image. They are produced only through the snapshot from sandbox by starting from an existing Windows sandbox and capturing its current state as a snapshot.
From public images
Section titled “From public images”Create a snapshot from any publicly accessible image or container registry.
- Go to Daytona Snapshots ↗
- Click the Create Snapshot button
- Enter the snapshot
nameandimageof any publicly accessible image or container registry
from daytona import Daytona, CreateSnapshotParams
daytona = Daytona()daytona.snapshot.create( CreateSnapshotParams(name="my-awesome-snapshot", image="python:3.11-slim"), on_logs=lambda chunk: print(chunk, end=""),)import { Daytona } from "@daytona/sdk";
const daytona = new Daytona();await daytona.snapshot.create( { name: "my-awesome-snapshot", image: "python:3.11-slim" }, { onLogs: console.log },);require 'daytona'
daytona = Daytona::Daytona.newparams = Daytona::CreateSnapshotParams.new( name: 'my-awesome-snapshot', image: 'python:3.11-slim')snapshot = daytona.snapshot.create(params) do |chunk| print chunkendpackage main
import ( "context" "github.com/daytona/clients/sdk-go/pkg/daytona" "github.com/daytona/clients/sdk-go/pkg/types")
func main() { client, _ := daytona.NewClient() ctx := context.Background() snapshot, logChan, _ := client.Snapshot.Create(ctx, &types.CreateSnapshotParams{ Name: "my-awesome-snapshot", Image: "python:3.11-slim", }) _ = snapshot for range logChan { }}import io.daytona.sdk.Daytona;import io.daytona.sdk.model.Snapshot;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { Snapshot snapshot = daytona.snapshot().create("my-awesome-snapshot", "python:3.11-slim"); } }}daytona snapshot create my-awesome-snapshot --image python:3.11-slimcurl https://app.daytona.io/api/snapshots \ --request POST \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \ --data '{ "name": "my-awesome-snapshot", "imageName": "python:3.11-slim" }'From local images
Section titled “From local images”Create a snapshot from local images or from local Dockerfiles.
Daytona expects the local image to be built for AMD64 architecture. Therefore, the --platform=linux/amd64 flag is required when building the Docker image if your machine is running on a different architecture.
- Ensure the image and tag you want to use is available
docker images- Create a snapshot and push it to Daytona:
daytona snapshot push custom-alpine:3.21 --name alpine-minimalAlternatively, use the --dockerfile flag under create to pass the path to the Dockerfile you want to use and Daytona will build the snapshot for you. The COPY/ADD commands will be automatically parsed and added to the context. To manually add files to the context, use the --context flag.
daytona snapshot create my-awesome-snapshot --dockerfile ./DockerfileFrom private registries
Section titled “From private registries”Create a snapshot from images from private container registries.
-
Go to Daytona Registries ↗
-
Click Add Registry and select your provider:
-
Enter the required fields
-
Go to Daytona Snapshots ↗
-
Click Create Snapshot
-
Enter the snapshot
nameand the fullimagereference, including the registry host and repository (e.g.my-registry.com/<repo>/custom-alpine:3.21)
Docker Hub
Section titled “Docker Hub”Create a snapshot from Docker Hub images.
-
Go to Daytona Registries ↗
-
Click Add Registry and select the Docker Hub tab
-
Input the following fields:
- Username: your Docker Hub username (the account with access to the image)
- Personal Access Token: a Docker Hub PAT; not your account password
- Registry URL: auto-filled with
docker.ioand not shown in the form
-
Create the snapshot using the full image reference
docker.io/<username>/<image>:<tag>
Google Artifact Registry
Section titled “Google Artifact Registry”Create a snapshot from images from Google Artifact Registry.
-
Go to Daytona Registries ↗,
-
Click Add Registry and select the Google tab
-
Input the following fields:
-
Registry URL: the base URL for your region
https://<region>-docker.pkg.dev -
Service Account JSON Key: the contents of your service account key JSON file
-
Google Cloud Project ID: your GCP project ID
-
Username: auto-filled with
_json_key(required by Google for service-account auth)
-
-
Create the snapshot using the full image reference
<region>-docker.pkg.dev/<project>/<repo>/<image>:<tag>
GitHub Container Registry
Section titled “GitHub Container Registry”Create a snapshot from images from GitHub Container Registry.
-
Go to Daytona Registries ↗,
-
Click Add Registry and select the GitHub tab
-
Input the following fields:
- GitHub Username: the account with access to the image
- Personal Access Token: a GitHub PAT with
read:packagesscope (andwrite:packages/delete:packagesfor pushing or deleting) - Registry URL: auto-filled with
ghcr.ioand not shown in the form
-
Create the snapshot using the full image reference
ghcr.io/<owner>/<image>:<tag>
Amazon ECR
Section titled “Amazon ECR”Create a snapshot from images from Amazon Elastic Container Registry.
Daytona pulls private ECR images via cross-account IAM role assumption. You create a role in your AWS account that trusts Daytona’s broker principal, and Daytona assumes it on every pull to fetch a short-lived ECR token.
-
Daytona Broker ARN
The IAM principal Daytona uses to assume into your role. Self-hosted: substitute the IAM role your API pods assume (e.g. via IRSA).
arn:aws:iam::967657494466:role/DaytonaEcrCredentialBroker -
External ID
Your Daytona organization ID, visible in the dashboard URL (
/dashboard/<orgId>/...) and on your organization settings page.
-
Create an IAM role in your AWS account
- Trust policy
{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Principal": { "AWS": "arn:aws:iam::967657494466:role/DaytonaEcrCredentialBroker" },"Action": "sts:AssumeRole","Condition": {"StringEquals": {"sts:ExternalId": "<YOUR_EXTERNAL_ID>"}}}]}- Permissions policy (read-only on ECR)
{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Action": ["ecr:GetAuthorizationToken","ecr:BatchCheckLayerAvailability","ecr:GetDownloadUrlForLayer","ecr:BatchGetImage"],"Resource": "*"}]} -
Go to Daytona Registries ↗
-
Click Add Registry and select the Amazon ECR tab
-
Input the following fields:
- Registry URL:
<account_id>.dkr.ecr.<region>.amazonaws.com - Role ARN: the role you created in step 1
Password is not used for ECR. Daytona resolves credentials server-side by assuming the role you created in step 1, using your organization ID as the
AssumeRole ExternalId. - Registry URL:
-
Go to Daytona Snapshots ↗
-
Click Create Snapshot
-
Enter the snapshot
nameand the fullimagereference<account_id>.dkr.ecr.<region>.amazonaws.com/<repo>/<image>:<tag> -
(Optional) Harden the trust policy
Daytona sends a
daytona-<orgId>-pullsession name on every AssumeRole call. You can require it in your trust policy for CloudTrail audit visibility. Add insideCondition:"StringLike": {"sts:RoleSessionName": "daytona-<YOUR_EXTERNAL_ID>-*"}
Get a snapshot by name
Section titled “Get a snapshot by name”Get a snapshot by name.
daytona.snapshot.get("my-awesome-snapshot")await daytona.snapshot.get('my-awesome-snapshot')daytona.snapshot.get('my-awesome-snapshot')_, err := client.Snapshots.Get(ctx, "my-awesome-snapshot")daytona.snapshot().get("my-awesome-snapshot");curl https://app.daytona.io/api/snapshots/my-awesome-snapshot \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN'List snapshots
Section titled “List snapshots”List snapshots and view their details.
daytona.snapshot.list(page=2, limit=10)await daytona.snapshot.list(2, 10)daytona.snapshot.list(page: 2, limit: 10)page, limit := 2, 10_, err := client.Snapshots.List(ctx, &page, &limit)daytona.snapshot().list(2, 10);# List snapshots with paginationdaytona snapshot list --page 2 --limit 10curl 'https://app.daytona.io/api/snapshots?page=2&limit=10' \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN'Activate snapshots
Section titled “Activate snapshots”Activate an inactive snapshot.
Snapshots automatically become inactive after 2 weeks of not being used.
- Go to Daytona Snapshots ↗
- Click the three dots at the end of the row for the snapshot you want to activate
- Click the Activate button
daytona.snapshot.activate("my-awesome-snapshot")await daytona.snapshot.activate("my-awesome-snapshot")daytona.snapshot.activate('my-awesome-snapshot')curl https://app.daytona.io/api/snapshots/my-inactive-snapshot/activate \ --request POST \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN'Deactivate snapshots
Section titled “Deactivate snapshots”Deactivate a snapshot.
Deactivated snapshots are not available for new sandboxes.
- Go to Daytona Snapshots ↗
- Click the three dots at the end of the row for the snapshot you want to deactivate
- Click the Deactivate button
Delete snapshots
Section titled “Delete snapshots”Delete a snapshot.
Deleted snapshots cannot be recovered.
- Go to Daytona Snapshots ↗
- Click the three dots at the end of the row for the snapshot you want to delete
- Click the Delete button
daytona.snapshot.delete(daytona.snapshot.get("my-awesome-snapshot"))await daytona.snapshot.delete(await daytona.snapshot.get("my-awesome-snapshot"))daytona.snapshot.delete(daytona.snapshot.get('my-awesome-snapshot'))snapshot, err := client.Snapshots.Get(ctx, "my-awesome-snapshot")err = client.Snapshots.Delete(ctx, snapshot)daytona.snapshot().delete(daytona.snapshot().get("my-awesome-snapshot").getId());daytona snapshot delete my-awesome-snapshotcurl https://app.daytona.io/api/snapshots/my-awesome-snapshot \ --request DELETE \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN'Snapshot lifecycle
Section titled “Snapshot lifecycle”A snapshot can have several different states. Each state reflects the snapshot’s current status.
- Pending: the snapshot creation has been requested
- Building: the snapshot is being built
- Pulling: the snapshot image is being pulled from a registry
- Active: the snapshot is ready to use for creating sandboxes
- Inactive: the snapshot is deactivated; must be explicitly activated before use
- Error: the snapshot creation failed
- Build Failed: the snapshot build process failed
- Removing: the snapshot is being deleted
Run Docker in a sandbox
Section titled “Run Docker in a sandbox”Sandboxes can run Docker containers inside them (Docker-in-Docker), enabling you to build, test, and deploy containerized applications.
Agents can interact with these services since they run within the same sandbox environment, providing better isolation and security compared to external service dependencies.
- Run databases (PostgreSQL, Redis, MySQL) and other services
- Build and test containerized applications
- Deploy microservices and their dependencies
- Create isolated development environments with full container orchestration
Create a Docker-in-Docker snapshot
Section titled “Create a Docker-in-Docker snapshot”Daytona provides an option to create a snapshot with Docker support using pre-built Docker-in-Docker images as a base or by manually installing Docker in a custom image.
Using pre-built images
Section titled “Using pre-built images”The following base images are widely used for creating Docker-in-Docker snapshots or can be used as a base for a custom Dockerfile:
docker:28.3.3-dind: official Docker-in-Docker image (Alpine-based, lightweight)docker:28.3.3-dind-rootless: rootless Docker-in-Docker for enhanced securitydocker:28.3.2-dind-alpine3.22: Docker-in-Docker image with Alpine 3.22
Manual installation
Alternatively, install Docker manually in a custom Dockerfile:
FROM ubuntu:22.04# Install Docker using the official install scriptRUN curl -fsSL https://get.docker.com | VERSION=28.3.3 sh -Run Docker Compose in a sandbox
Section titled “Run Docker Compose in a sandbox”Define and run multi-container applications. With Docker-in-Docker enabled in a Daytona sandbox, you can use Docker Compose to orchestrate services like databases, caches, and application containers.
- Create a Docker-in-Docker snapshot with one of the pre-built images
- Run Docker Compose services inside a sandbox
from daytona import Daytona, CreateSandboxFromSnapshotParams
# Initialize the Daytona clientdaytona = Daytona()
# Create a sandbox from a Docker-in-Docker snapshotsandbox = daytona.create(CreateSandboxFromSnapshotParams(snapshot='docker-dind'))
# Create a docker-compose.yml filecompose_content = '''services: web: image: nginx:alpine ports: - "8080:80"'''sandbox.fs.upload_file(compose_content.encode(), 'docker-compose.yml')
# Start Docker Compose servicesresult = sandbox.process.exec('docker compose -p demo up -d')print(result.result)
# Check running servicesresult = sandbox.process.exec('docker compose -p demo ps')print(result.result)
# Clean upsandbox.process.exec('docker compose -p demo down')import { Daytona } from '@daytona/sdk'
// Initialize the Daytona clientconst daytona = new Daytona()
// Create a sandbox from a Docker-in-Docker snapshotconst sandbox = await daytona.create({ snapshot: 'docker-dind' })
// Create a docker-compose.yml fileconst composeContent = `services: web: image: nginx:alpine ports: - "8080:80"`await sandbox.fs.uploadFile(Buffer.from(composeContent), 'docker-compose.yml')
// Start Docker Compose serviceslet result = await sandbox.process.executeCommand('docker compose -p demo up -d')console.log(result.result)
// Check running servicesresult = await sandbox.process.executeCommand('docker compose -p demo ps')console.log(result.result)
// Clean upawait sandbox.process.executeCommand('docker compose -p demo down')require 'daytona'
# Initialize the Daytona clientdaytona = Daytona::Daytona.new
# Create a sandbox from a Docker-in-Docker snapshotsandbox = daytona.create(Daytona::CreateSandboxFromSnapshotParams.new(snapshot: 'docker-dind'))
# Create a docker-compose.yml filecompose_content = <<~YAMLservices: web: image: nginx:alpine ports: - "8080:80"YAMLsandbox.fs.upload_file(compose_content, 'docker-compose.yml')
# Start Docker Compose servicesresult = sandbox.process.exec(command: 'docker compose -p demo up -d')puts result.result
# Check running servicesresult = sandbox.process.exec(command: 'docker compose -p demo ps')puts result.result
# Clean upsandbox.process.exec(command: 'docker compose -p demo down')package main
import ( "context" "fmt"
"github.com/daytonaio/sdk-go/daytona" "github.com/daytonaio/sdk-go/types")
func main() { ctx := context.Background()
// Initialize the Daytona client client, _ := daytona.NewDaytona(nil)
// Create a sandbox from a Docker-in-Docker snapshot sandbox, _ := client.Create(ctx, &types.CreateSandboxFromSnapshotParams{ Snapshot: daytona.Ptr("docker-dind"), }, nil)
// Create a docker-compose.yml file composeContent := `services: web: image: nginx:alpine ports: - "8080:80"` sandbox.Fs.UploadFile(ctx, []byte(composeContent), "docker-compose.yml")
// Start Docker Compose services result, _ := sandbox.Process.ExecuteCommand(ctx, "docker compose -p demo up -d", nil) fmt.Println(result.Result)
// Check running services result, _ = sandbox.Process.ExecuteCommand(ctx, "docker compose -p demo ps", nil) fmt.Println(result.Result)
// Clean up sandbox.Process.ExecuteCommand(ctx, "docker compose -p demo down", nil)}Run Kubernetes in a sandbox
Section titled “Run Kubernetes in a sandbox”Sandboxes can run a Kubernetes cluster inside the sandbox. Kubernetes runs entirely inside the sandbox and is removed when the sandbox is deleted, keeping environments secure and reproducible.
The snippet installs and starts a k3s cluster inside a sandbox and lists all running pods:
import { Daytona } from '@daytona/sdk'import { setTimeout } from 'timers/promises'
// Initialize the Daytona clientconst daytona = new Daytona()
// Create the sandbox instanceconst sandbox = await daytona.create()
// Run the k3s installation scriptconst response = await sandbox.process.executeCommand( 'curl -sfL https://get.k3s.io | sh -')
// Run k3sconst sessionName = 'k3s-server'await sandbox.process.createSession(sessionName)const k3s = await sandbox.process.executeSessionCommand(sessionName, { command: 'sudo /usr/local/bin/k3s server', async: true,})
// Give time to k3s to fully startawait setTimeout(30000)
// Get all podsconst pods = await sandbox.process.executeCommand( 'sudo /usr/local/bin/kubectl get pod -A')console.log(pods.result)