Skip to content

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).

Steps:

  1. Install latest E2B CLI
  2. Navigate to template folder (with e2b.toml and e2b.Dockerfile)
  3. Run migration command:
    bash
    e2b template migrate
  4. Follow prompts
  5. Done

Generated Output (JavaScript/TypeScript):

template.ts - Template definition using SDK
build.dev.ts - Development build script
build.prod.ts - Production build script

Note: 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:

  1. Build Docker image for linux/amd64 platform
  2. Push to registry
  3. 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

E2B Documentation • Generated from e2b.dev/docs