Skip to content

Commit 83619d8

Browse files
authored
Add exec command to the docs (#84)
1 parent 6534733 commit 83619d8

5 files changed

Lines changed: 97 additions & 15 deletions

File tree

docs.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,32 @@
166166
"docs/cli",
167167
"docs/cli/auth",
168168
"docs/cli/list-sandboxes",
169+
"docs/cli/create-sandbox",
170+
"docs/cli/connect-to-sandbox",
171+
"docs/cli/exec-command",
169172
"docs/cli/shutdown-sandboxes"
170173
]
171174
},
172175
{
173176
"group": "Deployment",
174-
"pages": ["docs/byoc"]
177+
"pages": [
178+
"docs/byoc"
179+
]
175180
},
176181
{
177182
"group": "Migration",
178-
"pages": ["docs/migration/v2"]
183+
"pages": [
184+
"docs/migration/v2"
185+
]
179186
},
180187
{
181188
"group": "Troubleshooting",
182189
"pages": [
183190
{
184191
"group": "SDKs",
185-
"pages": ["docs/troubleshooting/sdks/workers-edge-runtime"]
192+
"pages": [
193+
"docs/troubleshooting/sdks/workers-edge-runtime"
194+
]
186195
},
187196
{
188197
"group": "Templates",
@@ -312,4 +321,4 @@
312321
"permanent": true
313322
}
314323
]
315-
}
324+
}

docs/cli.mdx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "E2B CLI"
33
sidebarTitle: Installation
44
---
55

6-
E2B CLI is a command line tool that allows you to list, kill running sandboxes, and manage [sandbox templates](/docs/template/quickstart).
6+
E2B CLI is a command line tool that allows you to manage and interact with sandboxes and [templates](/docs/template/quickstart).
77

88
## Installation
99

@@ -24,13 +24,3 @@ You can install E2B CLI using the following command:
2424
npm i -g @e2b/cli
2525
```
2626
</CodeGroup>
27-
28-
### Beta CLI
29-
30-
The latest beta version of the CLI can be installed from NPM using the following command:
31-
32-
<CodeGroup>
33-
```bash Terminal
34-
npm i -g @e2b/cli@beta
35-
```
36-
</CodeGroup>

docs/cli/connect-to-sandbox.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "Connect to sandbox"
3+
---
4+
5+
You can connect an interactive terminal to an already running sandbox.
6+
7+
<CodeGroup>
8+
```bash Terminal
9+
e2b sandbox connect <sandbox-id>
10+
```
11+
</CodeGroup>
12+
13+
Unlike the `create` command, `connect` does not kill the sandbox when you disconnect. When you exit the terminal, only your terminal session is closed—the sandbox continues running.
14+
15+
Once connected, you can inspect the sandbox filesystem and processes to debug or experiment, or use it as a disposable environment for running agents instead of your local computer.

docs/cli/create-sandbox.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: "Create sandbox"
3+
---
4+
5+
You can create a sandbox and connect an interactive terminal to it.
6+
7+
<CodeGroup>
8+
```bash Terminal
9+
e2b sandbox create <template>
10+
```
11+
</CodeGroup>
12+
13+
For example, to create a sandbox from the `base` template:
14+
15+
```bash
16+
e2b sandbox create base
17+
```
18+
19+
This will:
20+
1. Create a new sandbox from the specified template
21+
2. Connect your terminal to the sandbox
22+
3. Keep the sandbox alive while you're connected
23+
4. Automatically kill the sandbox when you exit the terminal
24+
25+
Once connected, you can inspect the sandbox filesystem and processes to debug or experiment, or use it as a disposable environment for running agents instead of your local computer.

docs/cli/exec-command.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: "Execute commands in sandbox"
3+
---
4+
5+
You can execute commands in a running sandbox.
6+
7+
<CodeGroup>
8+
```bash Terminal
9+
e2b sandbox exec <sandbox-id> <command>
10+
```
11+
</CodeGroup>
12+
13+
### Run in background
14+
15+
Use the `--background` flag to run a command in the background and return immediately. The command will print the process ID (PID) to stderr:
16+
17+
```bash
18+
e2b sandbox exec --background <sandbox-id> "sleep 60 && echo done"
19+
```
20+
21+
### Set working directory
22+
23+
Use the `--cwd` flag to specify the working directory for the command:
24+
25+
```bash
26+
e2b sandbox exec --cwd /home/user <sandbox-id> ls
27+
```
28+
29+
### Run as specific user
30+
31+
Use the `--user` flag to run the command as a specific user:
32+
33+
```bash
34+
e2b sandbox exec --user root <sandbox-id> apt-get update
35+
```
36+
37+
### Set environment variables
38+
39+
Use the `--env` flag to set environment variables. This flag can be repeated for multiple variables:
40+
41+
```bash
42+
e2b sandbox exec --env NODE_ENV=production --env DEBUG=true <sandbox-id> node app.js
43+
```

0 commit comments

Comments
 (0)