You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/template/quickstart.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,8 @@ description: "Start with custom sandbox templates"
5
5
6
6
E2B templates allow you to define custom sandboxes.
7
7
You can define the base image, environment variables, files to copy, commands to run, and
8
-
a start command that will be already running when you spawn the sandbox.
9
-
This way, you can have fully configured sandboxes with running processes ready to use with zero wait time for your users.
8
+
a [start command](/docs/template/start-ready-command#start-command) that runs during the template build and is captured in a snapshot — so the process is **already running** when you create a sandbox from that template.
9
+
This gives you fully configured sandboxes with running processes ready to use with zero wait time for your users.
10
10
11
11
There are two ways how you can start creating a new template:
Copy file name to clipboardExpand all lines: docs/template/start-ready-command.mdx
+12-5Lines changed: 12 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,19 @@ description: "Define running processes for the sandbox"
4
4
---
5
5
6
6
## Start command
7
-
The start command allows you to specify a command that will be **already running**when you spawn your custom sandbox.
8
-
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.
7
+
The start command lets you specify a process that runs at the **end of the template build**— not when a sandbox is created.
8
+
During the build, E2B executes the start command, waits for the [ready command](#ready-command) to confirm the process is up, and then takes a [snapshot](/docs/template/how-it-works) of the entire sandbox including the running process.
9
9
10
-
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.
10
+
When you later create a sandbox from that template, the snapshotted process is **already running** — there is no startup wait.
11
+
This is how you get servers, seeded databases, or any long-running process available instantly when spawning sandboxes with the SDK.
11
12
12
-
You can see how it works [here](/docs/template/how-it-works).
13
+
<Notetitle="The start command does not run on sandbox creation">
14
+
The start command runs **once during template build** and is captured in a snapshot. It does not re-execute each time you create a sandbox. If you need to run a command every time a sandbox is created, use `sandbox.commands.run()` after creating the sandbox instead.
15
+
16
+
This also means that [environment variables passed to `Sandbox.create()`](/docs/sandbox/environment-variables#1-global-environment-variables) are **not available** to the start command process — it already ran during the build. If your start command needs environment variables, set them in the template definition using `setEnvs()` / `set_envs()`.
17
+
</Note>
18
+
19
+
You can see the full build process [here](/docs/template/how-it-works).
13
20
14
21
## Ready command
15
22
The ready command allows you to specify a command that will determine **template sandbox** readiness before a [snapshot](/docs/template/how-it-works) is created.
@@ -18,7 +25,7 @@ This way you can control how long should we wait for the [start command](/docs/t
18
25
19
26
## Usage
20
27
21
-
Set the command that runs when the sandbox starts and the command that determines when the sandbox is ready:
28
+
Set the start command (executed during template build) and the ready command (determines when the process is up before snapshotting):
0 commit comments