From ccaa8cef2b19b870c5c8cc2fbbe3d086b3e0c797 Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Tue, 3 Feb 2026 17:45:27 -0800 Subject: [PATCH 01/10] Add Docker template example documentation Add a new template example showing how to create a sandbox with Docker installed. Uses the official get.docker.com script for installation and validates with hello-world during build. --- docs.json | 3 +- docs/template/examples/docker.mdx | 88 +++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 docs/template/examples/docker.mdx diff --git a/docs.json b/docs.json index ca430977..bd5f51c7 100644 --- a/docs.json +++ b/docs.json @@ -120,7 +120,8 @@ "docs/template/examples/nextjs-bun", "docs/template/examples/expo", "docs/template/examples/desktop", - "docs/template/examples/claude-code" + "docs/template/examples/claude-code", + "docs/template/examples/docker" ] }, "docs/template/migration-v2", diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx new file mode 100644 index 00000000..0d1eee08 --- /dev/null +++ b/docs/template/examples/docker.mdx @@ -0,0 +1,88 @@ +--- +title: "Docker" +description: "Sandbox with Docker installed for running containers" +--- + +Run Docker containers inside the E2B sandbox. Docker daemon is managed by systemd and starts automatically. + +## Install Docker + +Use the official installation script from [get.docker.com](https://get.docker.com) to set up Docker. The `hello-world` container validates that everything works. + + +```typescript JavaScript & TypeScript +// template.ts +import { Template } from 'e2b' + +export const template = Template() + .fromUbuntuImage('25.04') + .runCmd('curl -fsSL https://get.docker.com | sudo sh') + .runCmd('sudo docker run --rm hello-world') +``` + +```python Python +# template.py +from e2b import Template + +template = ( + Template() + .from_ubuntu_image("25.04") + .run_cmd("curl -fsSL https://get.docker.com | sudo sh") + .run_cmd("sudo docker run --rm hello-world") +) +``` + + +## Build and publish + +Build the template with enough resources for Docker operations. + + +```typescript JavaScript & TypeScript +// build.ts +import { Template, defaultBuildLogger } from 'e2b' +import { template as dockerTemplate } from './template' + +await Template.build(dockerTemplate, 'e2b-docker-template', { + cpuCount: 2, + memoryMB: 2048, + onBuildLogs: defaultBuildLogger(), +}) +``` + +```python Python +# build.py +from e2b import Template, default_build_logger +from .template import template as dockerTemplate + +Template.build(dockerTemplate, 'e2b-docker-template', + cpu_count=2, + memory_mb=2048, + on_build_logs=default_build_logger(), +) +``` + + +## Run containers + +Spin up a sandbox and run any Docker image you need. + + +```typescript JavaScript & TypeScript +import { Sandbox } from 'e2b' + +const sandbox = await Sandbox.create('e2b-docker-template', { timeoutMs: 60_000 }) + +const result = await sandbox.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') +console.log(result.stdout) +``` + +```python Python +from e2b import Sandbox + +sandbox = Sandbox.create('e2b-docker-template', timeout=60) + +result = sandbox.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') +print(result.stdout) +``` + From f6f77a853bfb9a7da0815d3626c71bc380e7527e Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Wed, 4 Feb 2026 10:32:57 -0800 Subject: [PATCH 02/10] Match docker template format with other examples - Remove section headers - Use inline code comments instead of prose - Use sbx variable and sbx.kill() pattern - Simplify template name to 'docker' --- docs/template/examples/docker.mdx | 38 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx index 0d1eee08..229a984b 100644 --- a/docs/template/examples/docker.mdx +++ b/docs/template/examples/docker.mdx @@ -3,11 +3,7 @@ title: "Docker" description: "Sandbox with Docker installed for running containers" --- -Run Docker containers inside the E2B sandbox. Docker daemon is managed by systemd and starts automatically. - -## Install Docker - -Use the official installation script from [get.docker.com](https://get.docker.com) to set up Docker. The `hello-world` container validates that everything works. +Run Docker containers inside the sandbox. Docker daemon is managed by systemd and starts automatically. ```typescript JavaScript & TypeScript @@ -16,7 +12,9 @@ import { Template } from 'e2b' export const template = Template() .fromUbuntuImage('25.04') + // Install Docker using the official script .runCmd('curl -fsSL https://get.docker.com | sudo sh') + // Validate installation .runCmd('sudo docker run --rm hello-world') ``` @@ -27,23 +25,21 @@ from e2b import Template template = ( Template() .from_ubuntu_image("25.04") + # Install Docker using the official script .run_cmd("curl -fsSL https://get.docker.com | sudo sh") + # Validate installation .run_cmd("sudo docker run --rm hello-world") ) ``` -## Build and publish - -Build the template with enough resources for Docker operations. - ```typescript JavaScript & TypeScript // build.ts import { Template, defaultBuildLogger } from 'e2b' import { template as dockerTemplate } from './template' -await Template.build(dockerTemplate, 'e2b-docker-template', { +Template.build(dockerTemplate, 'docker', { cpuCount: 2, memoryMB: 2048, onBuildLogs: defaultBuildLogger(), @@ -55,7 +51,7 @@ await Template.build(dockerTemplate, 'e2b-docker-template', { from e2b import Template, default_build_logger from .template import template as dockerTemplate -Template.build(dockerTemplate, 'e2b-docker-template', +Template.build(dockerTemplate, 'docker', cpu_count=2, memory_mb=2048, on_build_logs=default_build_logger(), @@ -63,26 +59,30 @@ Template.build(dockerTemplate, 'e2b-docker-template', ``` -## Run containers - -Spin up a sandbox and run any Docker image you need. - ```typescript JavaScript & TypeScript +// sandbox.ts import { Sandbox } from 'e2b' -const sandbox = await Sandbox.create('e2b-docker-template', { timeoutMs: 60_000 }) +const sbx = await Sandbox.create('docker') -const result = await sandbox.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') +// Run any Docker container +const result = await sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') console.log(result.stdout) + +sbx.kill() ``` ```python Python +# sandbox.py from e2b import Sandbox -sandbox = Sandbox.create('e2b-docker-template', timeout=60) +sbx = Sandbox('docker') -result = sandbox.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') +# Run any Docker container +result = sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') print(result.stdout) + +sbx.kill() ``` From 7b77ec97cf8e54e31031ec7f09fe037f7ec2d0cd Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Wed, 4 Feb 2026 11:44:14 -0800 Subject: [PATCH 03/10] Add section headers and prose to docker template --- docs/template/examples/docker.mdx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx index 229a984b..860e6c37 100644 --- a/docs/template/examples/docker.mdx +++ b/docs/template/examples/docker.mdx @@ -5,6 +5,10 @@ description: "Sandbox with Docker installed for running containers" Run Docker containers inside the sandbox. Docker daemon is managed by systemd and starts automatically. +## Install Docker + +Use the official installation script from [get.docker.com](https://get.docker.com). The `hello-world` container validates the installation. + ```typescript JavaScript & TypeScript // template.ts @@ -12,9 +16,7 @@ import { Template } from 'e2b' export const template = Template() .fromUbuntuImage('25.04') - // Install Docker using the official script .runCmd('curl -fsSL https://get.docker.com | sudo sh') - // Validate installation .runCmd('sudo docker run --rm hello-world') ``` @@ -25,14 +27,14 @@ from e2b import Template template = ( Template() .from_ubuntu_image("25.04") - # Install Docker using the official script .run_cmd("curl -fsSL https://get.docker.com | sudo sh") - # Validate installation .run_cmd("sudo docker run --rm hello-world") ) ``` +## Build the template + ```typescript JavaScript & TypeScript // build.ts @@ -59,6 +61,8 @@ Template.build(dockerTemplate, 'docker', ``` +## Run containers + ```typescript JavaScript & TypeScript // sandbox.ts @@ -66,7 +70,6 @@ import { Sandbox } from 'e2b' const sbx = await Sandbox.create('docker') -// Run any Docker container const result = await sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') console.log(result.stdout) @@ -79,7 +82,6 @@ from e2b import Sandbox sbx = Sandbox('docker') -# Run any Docker container result = sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') print(result.stdout) From ade826a3564ade02116708f536844c8874b90ec0 Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Wed, 4 Feb 2026 11:45:17 -0800 Subject: [PATCH 04/10] Add RAM note to docker template build section --- docs/template/examples/docker.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx index 860e6c37..c9021c19 100644 --- a/docs/template/examples/docker.mdx +++ b/docs/template/examples/docker.mdx @@ -35,6 +35,10 @@ template = ( ## Build the template + + You may need to increase RAM if Docker containers cause out-of-memory errors. + + ```typescript JavaScript & TypeScript // build.ts From e49dfda08185e3a584554a9bde6c23052f16ea3d Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Wed, 4 Feb 2026 11:58:57 -0800 Subject: [PATCH 05/10] Fix Python Sandbox.create() in docker example --- docs/template/examples/docker.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx index c9021c19..d0ccfcd1 100644 --- a/docs/template/examples/docker.mdx +++ b/docs/template/examples/docker.mdx @@ -84,7 +84,7 @@ sbx.kill() # sandbox.py from e2b import Sandbox -sbx = Sandbox('docker') +sbx = Sandbox.create('docker') result = sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') print(result.stdout) From 32a1c64299678b48255ae5f2f39c9bfffaf27a89 Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Wed, 4 Feb 2026 12:04:49 -0800 Subject: [PATCH 06/10] Remove intro text from docker template --- docs/template/examples/docker.mdx | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx index d0ccfcd1..adb12fbe 100644 --- a/docs/template/examples/docker.mdx +++ b/docs/template/examples/docker.mdx @@ -3,8 +3,6 @@ title: "Docker" description: "Sandbox with Docker installed for running containers" --- -Run Docker containers inside the sandbox. Docker daemon is managed by systemd and starts automatically. - ## Install Docker Use the official installation script from [get.docker.com](https://get.docker.com). The `hello-world` container validates the installation. From d66c7e48ea1cd3ff71be087c08f5bf04ab3aca76 Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Wed, 4 Feb 2026 12:05:53 -0800 Subject: [PATCH 07/10] Match Python Sandbox pattern with other templates --- docs/template/examples/docker.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx index adb12fbe..9dae0925 100644 --- a/docs/template/examples/docker.mdx +++ b/docs/template/examples/docker.mdx @@ -82,7 +82,7 @@ sbx.kill() # sandbox.py from e2b import Sandbox -sbx = Sandbox.create('docker') +sbx = Sandbox('docker') result = sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') print(result.stdout) From 50bd00ed0f011d3f55077973c4c3a0aa9bd42922 Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Wed, 4 Feb 2026 14:53:31 -0800 Subject: [PATCH 08/10] Fix SDK patterns and add prose to docker template - Add await to sbx.kill() in TypeScript - Use Sandbox.create() pattern in Python - Add brief description to Run containers section --- docs/template/examples/docker.mdx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx index 9dae0925..541a764e 100644 --- a/docs/template/examples/docker.mdx +++ b/docs/template/examples/docker.mdx @@ -65,6 +65,8 @@ Template.build(dockerTemplate, 'docker', ## Run containers +Run an Alpine container that prints a hello message. + ```typescript JavaScript & TypeScript // sandbox.ts @@ -75,14 +77,14 @@ const sbx = await Sandbox.create('docker') const result = await sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') console.log(result.stdout) -sbx.kill() +await sbx.kill() ``` ```python Python # sandbox.py from e2b import Sandbox -sbx = Sandbox('docker') +sbx = Sandbox.create('docker') result = sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"') print(result.stdout) From e9a06b4c62213efd8ca05caa82ff7c62e2bfa4fa Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Thu, 5 Feb 2026 15:54:26 -0800 Subject: [PATCH 09/10] Improve build section with clearer RAM recommendation Replace Note with inline prose explaining recommended specs (2 CPUs, 2 GB RAM) and bold warning about lower RAM causing OOM errors. --- docs/template/examples/docker.mdx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx index 541a764e..b79fd2a7 100644 --- a/docs/template/examples/docker.mdx +++ b/docs/template/examples/docker.mdx @@ -33,9 +33,7 @@ template = ( ## Build the template - - You may need to increase RAM if Docker containers cause out-of-memory errors. - +We recommend at least 2 CPUs and 2 GB of RAM for running Docker containers. **With lower RAM, your sandbox might run out of memory when working with containers.** ```typescript JavaScript & TypeScript From 9750665923857e54b143887467b692dff7cbbfc3 Mon Sep 17 00:00:00 2001 From: Tomas Beran Date: Thu, 5 Feb 2026 16:01:50 -0800 Subject: [PATCH 10/10] Address review feedback on docker template - Add "run" to hello-world validation sentence - Simplify RAM warning text --- docs/template/examples/docker.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/template/examples/docker.mdx b/docs/template/examples/docker.mdx index b79fd2a7..718b5e2d 100644 --- a/docs/template/examples/docker.mdx +++ b/docs/template/examples/docker.mdx @@ -5,7 +5,7 @@ description: "Sandbox with Docker installed for running containers" ## Install Docker -Use the official installation script from [get.docker.com](https://get.docker.com). The `hello-world` container validates the installation. +Use the official installation script from [get.docker.com](https://get.docker.com). The `hello-world` container run validates the installation. ```typescript JavaScript & TypeScript @@ -33,7 +33,7 @@ template = ( ## Build the template -We recommend at least 2 CPUs and 2 GB of RAM for running Docker containers. **With lower RAM, your sandbox might run out of memory when working with containers.** +We recommend at least 2 CPUs and 2 GB of RAM for running Docker containers. **With lower RAM, your sandbox might run out of memory.** ```typescript JavaScript & TypeScript