You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document Docker image variants and Python migration
Sync documentation for PR #259: Optimize Docker image size with lean and Python variants
Changes:
- Add documentation for two image variants (default and -python)
- Include breaking change notice for Python users
- Add migration guide from v0.5.x to v0.6.0+
- Document PYTHON_NOT_AVAILABLE error behavior
- Update all examples to show appropriate image selection
- Clarify Python availability requirements in Code Interpreter API
Related upstream PR: cloudflare/sandbox-sdk#259
Copy file name to clipboardExpand all lines: src/content/docs/sandbox/api/interpreter.mdx
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,16 @@ import { TypeScriptExample } from "~/components";
9
9
10
10
Execute Python, JavaScript, and TypeScript code with support for data visualizations, tables, and rich output formats. Contexts maintain state (variables, imports, functions) across executions.
11
11
12
+
:::note[Python execution requires Python image]
13
+
To execute Python code, you must use the `-python` image variant in your Dockerfile:
14
+
15
+
```dockerfile
16
+
FROM docker.io/cloudflare/sandbox:0.6.0-python
17
+
```
18
+
19
+
The default image only supports JavaScript and TypeScript. Attempting to run Python code without the Python image will fail with a `PYTHON_NOT_AVAILABLE` error. See [Dockerfile reference](/sandbox/configuration/dockerfile/) for details on image variants.
Copy file name to clipboardExpand all lines: src/content/docs/sandbox/concepts/containers.mdx
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,14 @@ sidebar:
5
5
order: 3
6
6
---
7
7
8
-
Each sandbox runs in an isolated Linux container with Python, Node.js, and common development tools pre-installed. For a complete list of pre-installed software and how to customize the container image, see [Dockerfile reference](/sandbox/configuration/dockerfile/).
8
+
Each sandbox runs in an isolated Linux container with Node.js and common development tools pre-installed. Two image variants are available: a lean default image for shell and JavaScript workloads, and a Python-enabled image for data science tasks. For a complete list of pre-installed software and how to customize the container image, see [Dockerfile reference](/sandbox/configuration/dockerfile/).
9
9
10
10
## Runtime software installation
11
11
12
12
Install additional software at runtime using standard package managers:
13
13
14
14
```bash
15
-
# Python packages
15
+
# Python packages (requires Python image variant)
16
16
pip install scikit-learn tensorflow
17
17
18
18
# Node.js packages
@@ -22,6 +22,10 @@ npm install express
22
22
apt-get update && apt-get install -y redis-server
23
23
```
24
24
25
+
:::note[Python package installation]
26
+
Python package installation requires the `-python` image variant. See [Dockerfile reference](/sandbox/configuration/dockerfile/) for details on choosing the appropriate image variant.
27
+
:::
28
+
25
29
## Filesystem
26
30
27
31
The container provides a standard Linux filesystem. You can read and write anywhere you have permissions.
Copy file name to clipboardExpand all lines: src/content/docs/sandbox/configuration/dockerfile.mdx
+55-8Lines changed: 55 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,35 +9,81 @@ Customize the sandbox container image with your own packages, tools, and configu
9
9
10
10
## Base image
11
11
12
-
The Sandbox SDK uses a Ubuntu-based Linux container with Python, Node.js (via Bun), and common development tools pre-installed:
12
+
The Sandbox SDK provides two image variants: a lean image for shell and JavaScript workloads, and a Python-enabled image for data science and machine learning tasks.
13
+
14
+
### Image variants
15
+
16
+
**Default (lean)** - Shell and JavaScript/TypeScript execution (~600-800MB):
13
17
14
18
```dockerfile
15
19
FROM docker.io/cloudflare/sandbox:0.3.3
16
20
```
17
21
18
-
:::caution[Version synchronization required]
19
-
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` as your base image.
22
+
**Python variant** - Includes Python with data science packages (~1.3GB):
23
+
24
+
```dockerfile
25
+
FROM docker.io/cloudflare/sandbox:0.3.3-python
26
+
```
27
+
28
+
:::caution[Breaking change for Python users]
29
+
**Version 0.6.0+ requires explicit Python image**
30
+
31
+
Starting with version 0.6.0, the default image no longer includes Python. If you use the [Code Interpreter API](/sandbox/api/interpreter/) to run Python code, you must use the `-python` image variant.
32
+
33
+
**Migration required:**
34
+
35
+
```dockerfile
36
+
# Before (v0.5.x)
37
+
FROM docker.io/cloudflare/sandbox:0.5.6
38
+
39
+
# After (v0.6.0+)
40
+
FROM docker.io/cloudflare/sandbox:0.6.0-python
41
+
```
42
+
43
+
Without this change, Python execution will fail with a `PYTHON_NOT_AVAILABLE` error.
44
+
:::
45
+
46
+
:::note[Version synchronization required]
47
+
Always match the Docker image version to your npm package version. If you are using `@cloudflare/sandbox@0.3.3`, use `docker.io/cloudflare/sandbox:0.3.3` (or `0.3.3-python`) as your base image.
20
48
21
-
**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.
49
+
**Why this matters**: The SDK automatically checks version compatibility on startup. Mismatched versions can cause features to break or behave unexpectedly. If versions do not match, you will see warnings in your logs.
22
50
23
51
See [Version compatibility](/sandbox/concepts/sandboxes/#version-compatibility) for troubleshooting version mismatch warnings.
0 commit comments