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 your base image from its
/etc/os-release and supports Debian/Ubuntu, Fedora and the RHEL family (including Rocky Linux and AlmaLinux), Arch, and Alpine. Images with no identifiable distribution — no /etc/os-release, e.g. scratch, distroless, or pure nixos/nix — and minimal images missing required packages (e.g. RHEL UBI-minimal with restricted repositories) are not supported and fail the build with a clear error naming the reason.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.
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():