Skip to content

Commit 12357ec

Browse files
Document Docker image variants for sandbox-sdk
Add documentation for lean and Python image variants introduced in cloudflare/sandbox-sdk#259. This breaking change splits the base image into two variants optimized for different workloads. - Document default (lean) image without Python (~600-800MB) - Document Python image with data science packages (~1.3GB) - Add migration guide for users upgrading from 0.5.5 to 0.5.6+ - Document PYTHON_NOT_AVAILABLE error and how to resolve it - Update all Dockerfile examples to use 0.5.6 versions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c0e3b8e commit 12357ec

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/content/docs/sandbox/api/interpreter.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,26 @@ const ctx = await sandbox.createCodeContext({
3737
```
3838
</TypeScriptExample>
3939

40+
:::caution[Python requires the Python image]
41+
Creating a Python context requires the `-python` Docker image variant. The default lean image only supports JavaScript and TypeScript.
42+
43+
If you attempt to create a Python context without the Python image, you will receive a `PYTHON_NOT_AVAILABLE` error with HTTP status 501:
44+
45+
<TypeScriptExample>
46+
```
47+
try {
48+
const ctx = await sandbox.createCodeContext({ language: 'python' });
49+
} catch (error) {
50+
// SandboxError: Python is not available in this container image.
51+
// Use the cloudflare/sandbox:<version>-python image variant.
52+
console.error(error.message);
53+
}
54+
```
55+
</TypeScriptExample>
56+
57+
To fix this, update your Dockerfile to use the Python image variant. Refer to [Dockerfile reference](/sandbox/configuration/dockerfile/) for migration instructions.
58+
:::
59+
4060
### `runCode()`
4161

4262
Execute code in a context and return the complete result.

src/content/docs/sandbox/configuration/dockerfile.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The Sandbox SDK provides two image variants optimized for different use cases:
1616
Optimized for shell commands and JavaScript/TypeScript execution (~600-800MB):
1717

1818
```dockerfile
19-
FROM docker.io/cloudflare/sandbox:0.3.3
19+
FROM docker.io/cloudflare/sandbox:0.5.6
2020
```
2121

2222
**What's included:**
@@ -31,7 +31,7 @@ FROM docker.io/cloudflare/sandbox:0.3.3
3131
Full image with Python and data science packages (~1.3GB):
3232

3333
```dockerfile
34-
FROM docker.io/cloudflare/sandbox:0.3.3-python
34+
FROM docker.io/cloudflare/sandbox:0.5.6-python
3535
```
3636

3737
**What's included (in addition to default image):**
@@ -46,7 +46,7 @@ Using the lean image reduces image size by ~500MB and improves cold start times.
4646
:::
4747

4848
:::caution[Version synchronization required]
49-
Always match the Docker image version to your npm package version. If you're using `@cloudflare/sandbox@0.3.3`, use `docker.io/cloudflare/sandbox:0.3.3` (or `0.3.3-python`) as your base image.
49+
Always match the Docker image version to your npm package version. If you're using `@cloudflare/sandbox@0.5.6`, use `docker.io/cloudflare/sandbox:0.5.6` (or `0.5.6-python`) as your base image.
5050

5151
**Why this matters**: The SDK automatically checks version compatibility on startup. Mismatched versions can cause features to break or behave unexpectedly. If versions don't match, you'll see warnings in your logs.
5252

@@ -59,7 +59,7 @@ Create a `Dockerfile` in your project root:
5959

6060
```dockerfile title="Dockerfile"
6161
# Use Python variant if you need Python packages
62-
FROM docker.io/cloudflare/sandbox:0.3.3-python
62+
FROM docker.io/cloudflare/sandbox:0.5.6-python
6363

6464
# Install additional Python packages
6565
RUN pip install --no-cache-dir \
@@ -98,7 +98,7 @@ Run services automatically when the container starts by creating a custom startu
9898

9999
```dockerfile title="Dockerfile"
100100
# Choose appropriate variant (default or -python)
101-
FROM docker.io/cloudflare/sandbox:0.3.3
101+
FROM docker.io/cloudflare/sandbox:0.5.6
102102

103103
COPY my-app.js /workspace/my-app.js
104104
COPY startup.sh /workspace/startup.sh
@@ -146,7 +146,7 @@ If you attempt to execute Python code without the `-python` variant, you will re
146146

147147
## Related resources
148148

149-
- [Image Management](/containers/platform-details/image-management/) - Building and pushing images to Cloudflare\'s registry
149+
- [Image Management](/containers/platform-details/image-management/) - Building and pushing images to Cloudflare's registry
150150
- [Wrangler configuration](/sandbox/configuration/wrangler/) - Using custom images in wrangler.jsonc
151151
- [Docker documentation](https://docs.docker.com/reference/dockerfile/) - Complete Dockerfile syntax
152152
- [Container concepts](/sandbox/concepts/containers/) - Understanding the runtime environment

0 commit comments

Comments
 (0)