Skip to content

Commit f6f77a8

Browse files
committed
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'
1 parent ccaa8ce commit f6f77a8

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

docs/template/examples/docker.mdx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ title: "Docker"
33
description: "Sandbox with Docker installed for running containers"
44
---
55

6-
Run Docker containers inside the E2B sandbox. Docker daemon is managed by systemd and starts automatically.
7-
8-
## Install Docker
9-
10-
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.
6+
Run Docker containers inside the sandbox. Docker daemon is managed by systemd and starts automatically.
117

128
<CodeGroup>
139
```typescript JavaScript & TypeScript
@@ -16,7 +12,9 @@ import { Template } from 'e2b'
1612

1713
export const template = Template()
1814
.fromUbuntuImage('25.04')
15+
// Install Docker using the official script
1916
.runCmd('curl -fsSL https://get.docker.com | sudo sh')
17+
// Validate installation
2018
.runCmd('sudo docker run --rm hello-world')
2119
```
2220

@@ -27,23 +25,21 @@ from e2b import Template
2725
template = (
2826
Template()
2927
.from_ubuntu_image("25.04")
28+
# Install Docker using the official script
3029
.run_cmd("curl -fsSL https://get.docker.com | sudo sh")
30+
# Validate installation
3131
.run_cmd("sudo docker run --rm hello-world")
3232
)
3333
```
3434
</CodeGroup>
3535

36-
## Build and publish
37-
38-
Build the template with enough resources for Docker operations.
39-
4036
<CodeGroup>
4137
```typescript JavaScript & TypeScript
4238
// build.ts
4339
import { Template, defaultBuildLogger } from 'e2b'
4440
import { template as dockerTemplate } from './template'
4541

46-
await Template.build(dockerTemplate, 'e2b-docker-template', {
42+
Template.build(dockerTemplate, 'docker', {
4743
cpuCount: 2,
4844
memoryMB: 2048,
4945
onBuildLogs: defaultBuildLogger(),
@@ -55,34 +51,38 @@ await Template.build(dockerTemplate, 'e2b-docker-template', {
5551
from e2b import Template, default_build_logger
5652
from .template import template as dockerTemplate
5753

58-
Template.build(dockerTemplate, 'e2b-docker-template',
54+
Template.build(dockerTemplate, 'docker',
5955
cpu_count=2,
6056
memory_mb=2048,
6157
on_build_logs=default_build_logger(),
6258
)
6359
```
6460
</CodeGroup>
6561

66-
## Run containers
67-
68-
Spin up a sandbox and run any Docker image you need.
69-
7062
<CodeGroup>
7163
```typescript JavaScript & TypeScript
64+
// sandbox.ts
7265
import { Sandbox } from 'e2b'
7366

74-
const sandbox = await Sandbox.create('e2b-docker-template', { timeoutMs: 60_000 })
67+
const sbx = await Sandbox.create('docker')
7568

76-
const result = await sandbox.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"')
69+
// Run any Docker container
70+
const result = await sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"')
7771
console.log(result.stdout)
72+
73+
sbx.kill()
7874
```
7975

8076
```python Python
77+
# sandbox.py
8178
from e2b import Sandbox
8279

83-
sandbox = Sandbox.create('e2b-docker-template', timeout=60)
80+
sbx = Sandbox('docker')
8481

85-
result = sandbox.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"')
82+
# Run any Docker container
83+
result = sbx.commands.run('sudo docker run --rm alpine echo "Hello from Alpine!"')
8684
print(result.stdout)
85+
86+
sbx.kill()
8787
```
8888
</CodeGroup>

0 commit comments

Comments
 (0)