Creating template
When creating a template, you can specify options:.dockerignore files and combines them with your fileIgnorePatterns (TypeScript) or file_ignore_patterns (Python). Files matching these patterns are excluded from uploads and hash calculations.
Defining base image
Every template starts with a base image that provides the foundation for your sandbox environment. E2B identifies the image’s distribution from its/etc/os-release.
Supported: Debian/Ubuntu, Fedora and the RHEL family (including Rocky Linux and AlmaLinux), Arch, and Alpine.
Not supported:
- Images with no identifiable distribution (no
/etc/os-release), such asscratch, distroless, or purenixos/nix. - Minimal images missing required packages, such as RHEL UBI-minimal with restricted repositories.
Predefined base images
Use convenience methods for common base images with Ubuntu, Debian, Fedora, Alpine, Arch, Python, Node.js, or Bun:Custom base image
Use any Docker image from Docker Hub or other registries:Default E2B base image
Use the default E2B base image, which comes pre-configured for sandbox environments:base is also the template used when you call Sandbox.create() without specifying one. It is Debian-based and comes with common tooling pre-installed: Python 3, Node.js, Yarn, git, curl, build-essential, and the GitHub CLI (gh). For the exact contents, see the public Dockerfile: templates/base/e2b.Dockerfile.
NixOS base image
Arbitrary NixOS images (such asnixos/nix) aren’t supported directly, because they don’t expose the /etc/os-release metadata E2B needs to identify the distribution. To build NixOS-based sandboxes, use the official e2bdev/nixos image, which E2B prepares to work with the sandbox environment:
Default resources
A sandbox gets its CPU and memory from the template it’s built on. A sandbox built frombase starts with 2 vCPU and 512 MiB of RAM.
You can override CPU and memory when you build a template (cpuCount/cpu_count, memoryMB/memory_mb). Disk size is not a default you set per sandbox; it’s determined by your project’s tier limit and applied at build time (see Build limits).
Build from existing template
Extend an existing template from your project or organization:You can only call base image methods once per template. Subsequent calls will throw an error.
Parsing existing Dockerfiles
Convert existing Dockerfiles to template format usingfromDockerfile():