From 4299ea60280c2e33bfdffa9959ee49a52d295788 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 23 Apr 2026 16:12:11 +0800 Subject: [PATCH 1/2] docs: add sandbox CLI usage examples --- packages/cli/README.md | 86 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index 9009bd1523..aa473bc741 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -35,6 +35,90 @@ e2b auth login > [!IMPORTANT] > Note the distinction between `E2B_ACCESS_TOKEN` and `E2B_API_KEY`. -### 3. Check out docs +### 3. Common sandbox commands + +Create a sandbox from the default template: + +```bash +e2b sandbox create +``` + +Create a sandbox from a specific template without attaching a terminal: + +```bash +e2b sandbox create my-template --detach +``` + +List running sandboxes: + +```bash +e2b sandbox list +``` + +List running and paused sandboxes, limited to 20 results: + +```bash +e2b sandbox list --state running,paused --limit 20 +``` + +Filter sandboxes by metadata and print JSON: + +```bash +e2b sandbox list --metadata owner=agent --format json +``` + +Inspect a sandbox: + +```bash +e2b sandbox info +``` + +Connect an interactive terminal to a running sandbox: + +```bash +e2b sandbox connect +``` + +Stream sandbox logs until the sandbox closes: + +```bash +e2b sandbox logs --follow +``` + +Filter logs by level or logger prefix: + +```bash +e2b sandbox logs --follow --level warn +e2b sandbox logs --format json --loggers Envd,Kernel +``` + +View live resource metrics: + +```bash +e2b sandbox metrics --follow +``` + +Run a command in a running sandbox: + +```bash +e2b sandbox exec -- pwd +e2b sandbox exec -- python -V +``` + +Pass environment variables to a sandbox command: + +```bash +e2b sandbox exec -e FOO=bar -- sh -lc 'echo $FOO' +``` + +Pipe stdin into a sandbox command: + +```bash +cat script.py | e2b sandbox exec -- python +``` + +Use `--` before the remote command when you want to clearly separate CLI flags from the command being executed inside the sandbox. + +### 4. Check out docs Visit our [CLI documentation](https://e2b.dev/docs) to learn more. From 6a830b80949e761c81f28ea22de57c0adbeabcde Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 23 Apr 2026 16:22:54 +0800 Subject: [PATCH 2/2] docs: expand CLI README examples --- packages/cli/README.md | 79 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index aa473bc741..989c81d4cc 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -4,7 +4,7 @@ # E2B CLI -This CLI tool allows you to build manager your running E2B sandbox and sandbox templates. Learn more in [our documentation](https://e2b.dev/docs). +This CLI tool allows you to manage your running E2B sandboxes and sandbox templates. Learn more in [our documentation](https://e2b.dev/docs). ### 1. Install the CLI @@ -79,6 +79,24 @@ Connect an interactive terminal to a running sandbox: e2b sandbox connect ``` +Pause a running sandbox: + +```bash +e2b sandbox pause +``` + +Resume a paused sandbox: + +```bash +e2b sandbox resume +``` + +Kill a sandbox you no longer need: + +```bash +e2b sandbox kill +``` + Stream sandbox logs until the sandbox closes: ```bash @@ -105,6 +123,8 @@ e2b sandbox exec -- pwd e2b sandbox exec -- python -V ``` +Use `--` before the remote command to clearly separate CLI flags from the command being executed inside the sandbox. + Pass environment variables to a sandbox command: ```bash @@ -117,8 +137,61 @@ Pipe stdin into a sandbox command: cat script.py | e2b sandbox exec -- python ``` -Use `--` before the remote command when you want to clearly separate CLI flags from the command being executed inside the sandbox. +### 4. Common template commands + +Build a template from the current project: + +```bash +e2b template build +``` + +Build a template and assign it a specific template name: + +```bash +e2b template build --name my-template +``` + +Build a template from a specific path: + +```bash +e2b template build --path ./my-template +``` + +List available templates: + +```bash +e2b template list +``` + +Create a new template project: + +```bash +e2b template init +``` + +Delete a template you no longer need: + +```bash +e2b template delete