Skip to main content
We’ve made ready for you three ways how to migrate existing template to the new definition format.
  • Using the migration command (recommended)
  • Using the fromDockerfile() method to parse existing Dockerfile
  • Building the Docker image manually and using fromImage() method
This is handled for you automatically when using any of the options below.The default user for the template is user with the working directory set to the user home directory. This is a difference from the Docker defaults.
To migrate the existing template definition to the new format, follow these steps:
1

Install E2B CLI

Install the latest version of the E2B CLI
2

Navigate to your template folder

Navigate to the folder of your existing template definition (where you have e2b.toml and e2b.Dockerfile files).
3

Run migration command

e2b template migrate
4

Follow the prompts

Follow the prompts to complete the migration process.
5

Done

Generated Output

The migration command generates three files (based on the selected language).
template.ts - Template definition using the SDK
build.dev.ts - Development build script
build.prod.ts - Production build script

Using fromDockerfile() Method

If you want to keep using Dockerfile for your template, you can use the fromDockerfile() method. We’ll automatically parse the Dockerfile for you and build the template based on it. You can find more at Base Image.
// template.ts
import { Template } from "e2b";

const template = Template()
  .fromDockerfile(dockerfileContent);
Only a limited set of instructions are supported and converted to equivalent template.Compatible instructions:FROM, RUN, COPY, ADD, WORKDIR, USER, ENV, ARG, CMD, ENTRYPOINT
After the template definition, you can create the build scripts as described in the Quickstart section.

Using fromImage() Method

If you already have a Docker image built, or you want to keep building the Docker image yourself you can use the fromImage() method. Simply build the Docker image for the linux/amd64 platform, push it to a registry of your choice and reference the image tag in the fromImage() method. You can also specify credentials for private registries as described in the Base Image section.
// template.ts
import { Template } from "e2b";

const template = Template()
  .fromImage("image-tag");
I