Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 8934ddc

Browse files
authored
docs: Extend sandbox management guide (#364)
Signed-off-by: James Murdza <[email protected]>
1 parent 22c0949 commit 8934ddc

File tree

6 files changed

+473
-187
lines changed

6 files changed

+473
-187
lines changed

public/llms-full.txt

Lines changed: 104 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Daytona Documentation v0.21.0
2-
# Generated on: 2025-06-17
2+
# Generated on: 2025-06-27
33

44

55
title: API Keys
@@ -2240,38 +2240,48 @@ const daytona: Daytona = new Daytona({
22402240
title: Sandbox Management
22412241

22422242
import { Tabs, TabItem } from '@astrojs/starlight/components';
2243+
import Image from 'astro/components/Image.astro';
22432244

22442245
Sandboxes are isolated development environments managed by Daytona. This guide covers how to create, manage, and remove Sandboxes using the SDK.
22452246
By default, Sandboxes auto-stop after 15 minutes of inactivity and use **1 vCPU**, **1GB RAM**, and **3GiB disk**.
22462247

2248+
## Sandbox Lifecycle
2249+
2250+
Throughout its lifecycle, a Daytona Sandbox can have several different states. The diagram below shows the states and possible transitions between them.
2251+
2252+
<Fragment set:html={sandboxDiagram} />
2253+
2254+
By default, sandboxes auto-stop after `15 minutes` of inactivity and auto-archive after `7 days` of being stopped.
2255+
22472256
## Creating Sandboxes
22482257

2249-
Daytona SDK provides an option to create Sandboxes with default or custom configurations. You can specify the language, [Snapshot](/docs/snapshots), resources, environment variables, and volumes for the Sandbox.
2250-
By default, the Sandboxes auto-stop after `15 minutes` of inactivity in order to save resources but the timeout can be increased.
2258+
The Daytona SDK provides an option to create Sandboxes with default or custom configurations. You can specify the language, [Snapshot](/docs/snapshots), resources, environment variables, and volumes for the Sandbox.
2259+
Running Sandboxes utilize CPU, memory, and disk storage. Every resource is charged per second of usage.
22512260

22522261
:::tip
2253-
If you want to prolong the auto-stop interval, you can use the `auto_stop_interval` parameter when creating a Sandbox. The parameter is measured in minutes.
2254-
2255-
Setting the auto-stop interval parameter to `0` will disable the auto-stop functionality altogether and allow the sandbox to run indefinitely.
2262+
If you want to prolong the auto-stop interval, you can [set the auto-stop interval parameter](/docs/sandbox-management#auto-stop-interval) when creating a Sandbox.
22562263
:::
22572264

22582265
### Basic Sandbox Creation
22592266

2260-
Daytona SDK provides methods to create Sandboxes with default configurations, specific languages, or custom labels using Python and TypeScript.
2267+
The Daytona SDK provides methods to create Sandboxes with default configurations, specific languages, or custom labels using Python and TypeScript.
22612268

22622269
```python
22632270
from daytona import Daytona, CreateSandboxFromSnapshotParams
22642271

22652272
daytona = Daytona()
22662273

22672274
# Create a basic Sandbox
2275+
22682276
sandbox = daytona.create()
22692277

22702278
# Create a Sandbox with specific language
2279+
22712280
params = CreateSandboxFromSnapshotParams(language="python")
22722281
sandbox = daytona.create(params)
22732282

22742283
# Create a Sandbox with custom labels
2284+
22752285
params = CreateSandboxFromSnapshotParams(labels={"SOME_LABEL": "my-label"})
22762286
sandbox = daytona.create(params)
22772287

@@ -2293,6 +2303,8 @@ const sandbox = await daytona.create({ labels: { SOME_LABEL: 'my-label' } });
22932303
```
22942304

22952305

2306+
When Sandboxes are not actively used, it is recommended that they be stopped. This can be done manually [using the stop command](/docs/sandbox-management#stop-and-start-sandbox) or automatically by [setting the auto-stop interval](/docs/sandbox-management#auto-stop-and-auto-archive).
2307+
22962308
:::note
22972309
Daytona keeps a pool of warm Sandboxes using default Snapshots.
22982310
When available, your Sandbox will launch in milliseconds instead of cold-booting.
@@ -2312,6 +2324,7 @@ from daytona import Daytona, Resources, CreateSandboxFromImageParams, Image
23122324
daytona = Daytona()
23132325

23142326
# Create a Sandbox with custom resources
2327+
23152328
resources = Resources(
23162329
cpu=2, # 2 CPU cores
23172330
memory=4, # 4GB RAM
@@ -2353,16 +2366,18 @@ All resource parameters are optional. If not specified, Daytona will use default
23532366

23542367
## Sandbox Information
23552368

2356-
Daytona SDK provides methods to get information about a Sandbox, such as ID, root directory, and status using Python and TypeScript.
2369+
The Daytona SDK provides methods to get information about a Sandbox, such as ID, root directory, and status using Python and TypeScript.
23572370

23582371
```python
23592372
# Get Sandbox ID
23602373
sandbox_id = sandbox.id
23612374

23622375
# Get the root directory of the Sandbox user
2376+
23632377
root_dir = sandbox.get_user_root_dir()
23642378

23652379
# Get the Sandbox id, auto-stop interval and state
2380+
23662381
print(sandbox.id)
23672382
print(sandbox.auto_stop_interval)
23682383
print(sandbox.state)
@@ -2385,22 +2400,76 @@ console.log(sandbox.state)
23852400

23862401
To get the preview URL for a specific port, check out [Preview & Authentication](/docs/preview-and-authentication).
23872402

2388-
## Stop & Remove Sandbox
2403+
## Stop and Start Sandbox
23892404

2390-
Daytona SDK provides methods to stop and delete Sandboxes using Python and TypeScript.
2405+
The Daytona SDK provides methods to stop and start Sandboxes using Python and TypeScript.
2406+
2407+
Stopped Sandboxes maintain filesystem persistence while their memory state is cleared. They incur only disk usage costs and can be started again when needed.
23912408

23922409
```python
2410+
sandbox = daytona.create(CreateSandboxParams(language="python"))
2411+
23932412
# Stop Sandbox
2413+
23942414
sandbox.stop()
23952415

2396-
# Delete Sandbox
2397-
sandbox.delete()
2416+
print(sandbox.id) # 7cd11133-96c1-4cc8-9baa-c757b8f8c916
2417+
2418+
# The sandbox ID can later be used to find the sandbox and start it
2419+
2420+
sandbox = daytona.find_one("7cd11133-96c1-4cc8-9baa-c757b8f8c916")
2421+
2422+
# Start Sandbox
2423+
2424+
sandbox.start()
23982425

23992426
```
24002427
```typescript
2428+
const sandbox = await daytona.create({ language: 'typescript' });
2429+
24012430
// Stop Sandbox
24022431
await sandbox.stop();
24032432

2433+
console.log(sandbox.id) // 7cd11133-96c1-4cc8-9baa-c757b8f8c916
2434+
2435+
// The sandbox ID can later be used to find the sandbox and start it
2436+
2437+
const sandbox = await daytona.findOne("7cd11133-96c1-4cc8-9baa-c757b8f8c916");
2438+
2439+
// Start Sandbox
2440+
await sandbox.start();
2441+
```
2442+
2443+
2444+
The stopped state should be used when the Sandbox is expected to be started again soon. Otherwise, it is recommended to stop and then archive the Sandbox to eliminate disk usage costs.
2445+
2446+
## Archive Sandbox
2447+
2448+
The Daytona SDK provides methods to archive Sandboxes using Python and TypeScript.
2449+
2450+
When Sandboxes are archived, the entire filesystem state is moved to very cost-effective object storage, making it possible to keep Sandboxes available for an extended period.
2451+
Starting an archived Sandbox takes more time than starting a stopped Sandbox, depending on its size.
2452+
2453+
A Sandbox must be stopped before it can be archived, and can be started again in the same way as a stopped Sandbox.
2454+
2455+
```python
2456+
# Archive Sandbox
2457+
sandbox.archive()
2458+
```
2459+
```typescript
2460+
// Archive Sandbox
2461+
await sandbox.archive();
2462+
```
2463+
2464+
## Delete Sandbox
2465+
2466+
The Daytona SDK provides methods to delete Sandboxes using Python and TypeScript.
2467+
2468+
```python
2469+
# Delete Sandbox
2470+
sandbox.delete()
2471+
```
2472+
```typescript
24042473
// Delete Sandbox
24052474
await sandbox.delete();
24062475
```
@@ -2435,13 +2504,22 @@ All sandboxes have been deleted
24352504

24362505
:::
24372506

2438-
## Sandbox States and Persistence
2507+
## Auto-stop and Auto-archive
24392508

2440-
Daytona keeps the filesystem in its entirety during the Sandbox lifecycle. The persistence functionality is built into the system, and nothing needs to be explicitly done from the user side.
2509+
Daytona Sandboxes can be automatically stopped and archived based on user-defined intervals.
24412510

24422511
### Auto-stop Interval
24432512

2444-
It is important to understand the Sandbox states to maintain cost-effectiveness. One useful built-in feature is the auto-stop interval. By default, it triggers after `15 minutes` of inactivity by stopping the Sandbox, but the number can changed to any value, including `0` which disables auto-stopping.
2513+
The auto-stop interval parameter sets the amount of time after which a running Sandbox will be automatically stopped.
2514+
2515+
The parameter can either be set to:
2516+
2517+
- a time interval in minutes
2518+
- `0`, which disables the auto-stop functionality, allowing the sandbox to run indefinitely
2519+
2520+
If the parameter is not set, the default interval of `15` minutes will be used.
2521+
2522+
:::
24452523

24462524
```python
24472525
sandbox = daytona.create(CreateSandboxFromSnapshotParams(
@@ -2459,7 +2537,14 @@ const sandbox = await daytona.create({
24592537

24602538
### Auto-archive Interval
24612539

2462-
Another useful built-in feature is the auto-archive interval. By default, it triggers after a Sandbox has been continuously stopped for `7 days` by archiving it, but the number can changed to any value, including `0` which means the maximum interval of `30 days` will be used.
2540+
The auto-archive interval parameter sets the amount of time after which a continuously stopped Sandbox will be automatically archived.
2541+
2542+
The parameter can either be set to:
2543+
2544+
- a time interval in minutes
2545+
- `0`, which means the maximum interval of `30 days` will be used
2546+
2547+
If the parameter is not set, the default interval of `7 days` days will be used.
24632548

24642549
```python
24652550
sandbox = daytona.create(CreateSandboxFromSnapshotParams(
@@ -2474,27 +2559,6 @@ const sandbox = await daytona.create({
24742559
});
24752560
```
24762561

2477-
A Daytona Sandbox can have three states during its lifecycle:
2478-
2479-
### Running
2480-
2481-
Running Sandboxes utilize CPU, memory, and disk storage. Every resource is charged per second of usage. When Sandboxes are not actively used, it is recommended that they be stopped. This can be done:
2482-
2483-
- Manually using the stop command
2484-
- Automatically by setting the autoStop interval
2485-
2486-
### Stopped
2487-
2488-
Stopped Sandboxes only utilize disk storage. They can be instantly started when needed. The stopped state should be used when the Sandbox is expected to be started again soon. Otherwise, it is recommended to archive the Sandbox to eliminate disk usage costs.
2489-
2490-
### Archived
2491-
2492-
When Sandboxes are archived, the entire filesystem state is moved to very cost-effective object storage, making it possible to keep Sandboxes available for an extended period.
2493-
2494-
### Performance Considerations
2495-
2496-
The tradeoff between archived and stopped states is that starting an archived Sandbox takes more time, depending on its size.
2497-
24982562
title: Snapshots
24992563

25002564
import { TabItem, Tabs } from '@astrojs/starlight/components'
@@ -2602,6 +2666,7 @@ from daytona import (
26022666
daytona = Daytona()
26032667

26042668
# Create a Snapshot with custom resources
2669+
26052670
daytona.snapshot.create(
26062671
CreateSnapshotParams(
26072672
name="my-snapshot",
@@ -2616,11 +2681,13 @@ daytona.snapshot.create(
26162681
)
26172682

26182683
# Create a Sandbox with custom Snapshot
2684+
26192685
sandbox = daytona.create(
26202686
CreateSandboxFromSnapshotParams(
26212687
snapshot="my-snapshot",
26222688
)
26232689
)
2690+
26242691
```
26252692
```typescript
26262693
import { Daytona, Image } from "@daytonaio/sdk";

public/llms.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Daytona Documentation v0.21.0
2-
# Generated on: 2025-06-17
2+
# Generated on: 2025-06-27
33

44
# Daytona
55

@@ -113,18 +113,17 @@
113113
- [Resource Limits](https://daytona.io/docs/process-code-execution#resource-limits)
114114
- [Region Selection](https://daytona.io/docs/regions)
115115
- [Sandbox Management](https://daytona.io/docs/sandbox-management)
116+
- [Sandbox Lifecycle](https://daytona.io/docs/sandbox-management#sandbox-lifecycle)
116117
- [Creating Sandboxes](https://daytona.io/docs/sandbox-management#creating-sandboxes)
117118
- [Basic Sandbox Creation](https://daytona.io/docs/sandbox-management#basic-sandbox-creation)
118119
- [Sandbox Resources](https://daytona.io/docs/sandbox-management#sandbox-resources)
119120
- [Sandbox Information](https://daytona.io/docs/sandbox-management#sandbox-information)
120-
- [Stop & Remove Sandbox](https://daytona.io/docs/sandbox-management#stop--remove-sandbox)
121-
- [Sandbox States and Persistence](https://daytona.io/docs/sandbox-management#sandbox-states-and-persistence)
121+
- [Stop and Start Sandbox](https://daytona.io/docs/sandbox-management#stop-and-start-sandbox)
122+
- [Archive Sandbox](https://daytona.io/docs/sandbox-management#archive-sandbox)
123+
- [Delete Sandbox](https://daytona.io/docs/sandbox-management#delete-sandbox)
124+
- [Auto-stop and Auto-archive](https://daytona.io/docs/sandbox-management#auto-stop-and-auto-archive)
122125
- [Auto-stop Interval](https://daytona.io/docs/sandbox-management#auto-stop-interval)
123126
- [Auto-archive Interval](https://daytona.io/docs/sandbox-management#auto-archive-interval)
124-
- [Running](https://daytona.io/docs/sandbox-management#running)
125-
- [Stopped](https://daytona.io/docs/sandbox-management#stopped)
126-
- [Archived](https://daytona.io/docs/sandbox-management#archived)
127-
- [Performance Considerations](https://daytona.io/docs/sandbox-management#performance-considerations)
128127
- [Snapshots](https://daytona.io/docs/snapshots)
129128
- [Creating Snapshots](https://daytona.io/docs/snapshots#creating-snapshots)
130129
- [Snapshot Resources](https://daytona.io/docs/snapshots#snapshot-resources)

0 commit comments

Comments
 (0)