> ## Documentation Index
> Fetch the complete documentation index at: https://e2b.manicule.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://e2b.manicule.dev/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://e2b.manicule.dev/api/mcp.
> Every agent surface: https://e2b.manicule.dev/.well-known/llms-manifest.json

# V2 build system migration (/docs/migration/template-v2)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 915 · updated: 2026-07-30 -->
Related: [SDK v2 migration guide](/docs/migration/v2.md), [E2B_ACCESS_TOKEN deprecation](/docs/migration/access-token-deprecation.md), [V1 build system deprecation](/docs/migration/v1-build-deprecation.md)

> How to migrate from the legacy template definition

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

<Warning>
  *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.
</Warning>

## Migration command (recommended)

To migrate the existing template definition to the new format, follow these steps:

<Steps>
<Step title="Install E2B CLI">Install the latest version of the [E2B CLI](https://e2b.dev/docs/cli)</Step>

<Step title="Navigate to your template folder">Navigate to the folder of your existing template definition (where you have `e2b.toml` and `e2b.Dockerfile` files).</Step>

  <Step title="Run migration command">
<Note>Your existing `e2b.toml` and `e2b.Dockerfile` files will be renamed to `e2b.toml.old` and `e2b.Dockerfile.old`, respectively, as they are no longer required.</Note>

    ```bash
    e2b template migrate
    ```
  </Step>

<Step title="Follow the prompts">Follow the prompts to complete the migration process.</Step>

  <Step title="Done" />
</Steps>

### Generated output

The migration command generates three files (based on the selected language).

<CodeGroup>
```markdown title="JavaScript & TypeScript"
template.ts - Template definition using the SDK
build.dev.ts - Development build script
build.prod.ts - Production build script
```

```markdown title="Python"
template.py - Template definition using the SDK
build_dev.py - Development build script
build_prod.py - Production build script
```
</CodeGroup>

## 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](/docs/template/base-image#parsing-existing-dockerfiles).

<CodeGroup>
```typescript title="JavaScript & TypeScript"
// template.ts
import { Template } from 'e2b';

const template = Template()
  .fromDockerfile(dockerfileContent);
```

```python title="Python"
# template.py
from e2b import Template

template = (
    Template()
    .from_dockerfile(dockerfile_content)
)
```
</CodeGroup>

<Info>
  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`
</Info>

After the template definition, you can create the build scripts as described in the [Quickstart](/docs/template/quickstart#create-a-development-build-script) 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](/docs/template/base-image#custom-base-image) section.

<CodeGroup>
```typescript title="JavaScript & TypeScript"
// template.ts
import { Template } from 'e2b';

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

```python title="Python"
# template.py
from e2b import Template

template = (
    Template()
    .from_image("image-tag")
)
```
</CodeGroup>
