Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Update docs
Vasek Mlejnskyd4871849355a
diff --git a/apps/docs/src/app/sandbox/templates/start-cmd/page.mdx b/apps/docs/src/app/sandbox/templates/start-cmd/page.mdxindex 0e125fb2f..71fdb6269 100644--- a/apps/docs/src/app/sandbox/templates/start-cmd/page.mdx+++ b/apps/docs/src/app/sandbox/templates/start-cmd/page.mdx@@ -1,29 +1,55 @@# Start Command+Start command allows you to specify a command that will be **already running** when you spawn your custom sandbox.+This way, you can for example have running servers or seeded databases inside the sandbox that are already fully ready when you spawn the sandbox using the SDK and with zero waiting time for your users during the runtime.-Custom sandboxes allow you to specify a command that will be running when a sandbox is spawned.+The idea behind the start command feature is to lower the wait times for your users and have everything ready for your users when you spawn your sandbox.-This way you can run a command that will start your app, or run a command that will start a specific process.+## How it works+When building a custom sandbox, we create a container based on your [`e2b.Dockerfile`](/sandbox/templates/template-file) file.+We extract the container's filesystem and start a sandbox with this extracted filesystem.+We call this sandbox a _template sandbox_. Now two things can happen depending whether you specified the start command or not.+- **If you don't specify the start command**+ 1. we take the running template sandbox+ 1. snapshot it and make it ready for you to spawn it with the SDK-## How to add a start command+- **If you do specify the start command**+ 1. we take the running template sandbox+ 1. **execute the start command and wait 15 seconds**+ 1. snapshot it and make it ready for you to spawn it with the SDK+++<Note title="Sandbox Snapshot">+Snapshots are saved running sandboxes. We serialize and save the whole sandbox's filesystem together with all the running processes in a way that can be loaded later.++This allows us to load the sandbox in a few hundred milliseconds any time later with all the processes already running and the filesystem exactly as it was.+</Note>+++## Limits+- The network isn't accessible when running the start command.+- We wait 15 seconds after we execute the start command before we snapshot the sandbox.+++## How to add start commandWhen you are building a sandbox template you can specify the start command by using the [`-c`](/cli/commands#build) option:```bash-e2b build -c "npm start"+e2b build -c "<your-start-command>"```-After the sandbox template is built, when you spawn a sandbox the start command will be running if there was no error when it tried to start.--You can check the logs from the start command by using the SDKs:+When you spawn the custom sandbox you built, the start command will be already running if there was no error when we tried to execute it.+## Logs+You can retrieve the start command's logs using the SDK during runtime:<CodeGroup title="Check start command logs" isRunnable={false}>```js {{ language: 'js' }}import { Sandbox } from '@e2b/sdk'// Spawn your custom sandbox-const sandbox = await Sandbox.create({+const sandbox = await Sandbox.create({id: 'my-agent-sandbox',// If you specify onStderr and onStdout handlers when spawning the sandbox// you will see logs from the start command.@@ -53,17 +79,14 @@ sandbox.close()</CodeGroup>-### Sandbox template config---You can find the start command for the sandbox template in the `e2b.toml`:-+## Sandbox template config+The start command is specified inside the `e2b.toml` in the same directory where you ran `e2b build -c "<your-start-command>"`.<CodeGroup isFileName title="e2b.toml" isRunnable={false}>```toml# This is a config for E2B sandbox templateid = "1wdqsf9le9gk21ztb4mo"dockerfile = "e2b.Dockerfile"name = "my-agent-sandbox"-start_cmd = "npm start" # $HighlightLine+start_cmd = "<your-start-command>" # $HighlightLine```</CodeGroup>diff --git a/apps/docs/src/components/Navigation/routes.tsx b/apps/docs/src/components/Navigation/routes.tsxindex 75d4de446..e4391f4c8 100644--- a/apps/docs/src/components/Navigation/routes.tsx+++ b/apps/docs/src/components/Navigation/routes.tsx@@ -161,33 +161,33 @@ export const routes = [},{icon: (- <Hammer+ <PlaySquarestrokeWidth={1}size={20}/>),- title: 'Guide: Creating Custom Sandbox',- href: '/guide/custom-sandbox',+ title: 'Start Command',+ href: '/sandbox/templates/start-cmd',},{icon: (- <PlaySquare+ <BoxesstrokeWidth={1}size={20}/>),- title: 'Start Command',- href: '/sandbox/templates/start-cmd',+ title: 'Premade Sandboxes',+ href: '/sandbox/templates/premade',},{icon: (- <Boxes+ <HammerstrokeWidth={1}size={20}/>),- title: 'Premade Sandboxes',- href: '/sandbox/templates/premade',+ title: 'Guide: Creating Custom Sandbox',+ href: '/guide/custom-sandbox',},]},