E2B CLI
This CLI tool allows you to build and manage E2B sandbox templates.
You define your sandbox template with an e2b.Dockerfile and then use the CLI e2b template build to build the sandbox template.
You can then create a sandbox from a template with E2B SDKs and run your AI agents or execute code.
The e2b.Dockerfile is the same as for Docker, but you can only use Debian-based Linux distros as the base image.
Installation
npm install -g @e2b/cli
Then you can use the CLI like this:
e2b --help
Getting started
- Authenticate with
e2b auth login
To authenticate without the ability to open the browser, provide
E2B_ACCESS_TOKENas an environment variable. Get yourE2B_ACCESS_TOKENfrom e2b.dev/docs. Then use the CLI like this:E2B_ACCESS_TOKEN=sk_e2b_... e2b build.
- Create an
e2b.Dockerfilewhere you describe how your custom E2B sandbox template should look like. The majority of Debian-based Linux distros should work as the base image. Here is an example of a minimalDockerfilefor an E2B sandbox template:
FROM ubuntu:22.04
-
Run
e2b template buildinside the directory with thee2b.Dockerfileto create and build the sandbox template. You will get the template ID to use for creating sandboxes with E2B SDKs. Thee2b.tomlfile will be created automatically in the same directory -
Use the template ID that you got during the
e2b template buildwith the Python or JS/TS SDK as theidto create a sandbox -
Rebuild the sandbox template by running
e2b template buildin the directory with thee2b.Dockerfileande2b.tomlfiles
Commands
All commands can be called with a --path <path-to-dir> flag that changes the
directory where the command will be called without the need to call cd.
-V, --version Display E2B CLI version
-h, --help display help for command