diff --git a/packages/cli/README.md b/packages/cli/README.md index 9009bd1523..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 @@ -35,6 +35,163 @@ 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 +``` + +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 +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 +``` + +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 +e2b sandbox exec -e FOO=bar -- sh -lc 'echo $FOO' +``` + +Pipe stdin into a sandbox command: + +```bash +cat script.py | e2b sandbox exec -- python +``` + +### 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