Template Migration V2 Guide
Three ways to migrate existing template to new definition format:
Note: Default user for template is user with working directory set to user home directory (different from Docker defaults).
1. Migration Command (Recommended)
Steps:
- Install latest E2B CLI
- Navigate to template folder (with
e2b.tomlande2b.Dockerfile) - Run migration command:bash
e2b template migrate - Follow prompts
- Done
Generated Output (JavaScript/TypeScript):
template.ts - Template definition using SDK
build.dev.ts - Development build script
build.prod.ts - Production build scriptNote: Existing e2b.toml and e2b.Dockerfile renamed to .old (no longer required)
2. Using fromDockerfile() Method
Keep using Dockerfile. E2B automatically parses and builds from it.
javascript
// template.ts
import { Template } from "e2b";
const template = Template()
.fromDockerfile(dockerfileContent);Supported Instructions:
- Compatible:
FROM,RUN,COPY,ADD,WORKDIR,USER,ENV,ARG,CMD,ENTRYPOINT - Only limited set supported and converted to equivalent template
See: Base Image Documentation - Parsing Existing Dockerfiles
3. Using fromImage() Method
Use pre-built Docker image or build yourself.
Steps:
- Build Docker image for
linux/amd64platform - Push to registry
- Reference in template:javascript
// template.ts import { Template } from "e2b"; const template = Template() .fromImage("image-tag");
Private Registries: Specify credentials as described in Base Image - Custom Base Image