|
| 1 | +--- |
| 2 | +title: Sandbox SDK introduces lean and Python image variants |
| 3 | +description: Reduce Docker image size by up to 500MB with new image variants optimized for different workloads. Choose the lean image for shell and JavaScript execution or the Python variant for data science workflows. |
| 4 | +products: |
| 5 | + - agents |
| 6 | + - workers |
| 7 | +date: 2025-11-27 |
| 8 | +--- |
| 9 | + |
| 10 | +The Sandbox SDK now provides two optimized Docker image variants to improve cold start times and reduce storage costs: |
| 11 | + |
| 12 | +- **Default image** (~600-800MB): Lean image without Python, ideal for shell commands, JavaScript, and TypeScript execution |
| 13 | +- **Python image** (~1.3GB): Full-featured image with Python 3.11 and data science packages (matplotlib, numpy, pandas, ipython) |
| 14 | + |
| 15 | +### Choosing the right image |
| 16 | + |
| 17 | +Use the default image for most workloads: |
| 18 | + |
| 19 | +```dockerfile |
| 20 | +FROM docker.io/cloudflare/sandbox:0.6.0 |
| 21 | +``` |
| 22 | + |
| 23 | +Only use the Python variant if you need Python code execution with the [Code Interpreter API](/sandbox/api/interpreter/): |
| 24 | + |
| 25 | +```dockerfile |
| 26 | +FROM docker.io/cloudflare/sandbox:0.6.0-python |
| 27 | +``` |
| 28 | + |
| 29 | +### Migration guide |
| 30 | + |
| 31 | +**If you are NOT using Python code execution**, no changes are required. Your existing Dockerfile will automatically use the smaller default image on the next release. |
| 32 | + |
| 33 | +**If you ARE using Python** (via `runCode()` or `createCodeContext()` with Python), update your Dockerfile to explicitly use the `-python` variant: |
| 34 | + |
| 35 | +```dockerfile |
| 36 | +# Before (implicit Python support) |
| 37 | +FROM docker.io/cloudflare/sandbox:0.5.0 |
| 38 | + |
| 39 | +# After (explicit Python variant) |
| 40 | +FROM docker.io/cloudflare/sandbox:0.6.0-python |
| 41 | +``` |
| 42 | + |
| 43 | +Without this change, attempts to execute Python code on the lean image will return a clear error message indicating that the Python variant is required. |
| 44 | + |
| 45 | +### Benefits |
| 46 | + |
| 47 | +- **Faster cold starts**: The lean image is approximately 40% smaller |
| 48 | +- **Lower storage costs**: Reduced image size means less storage consumption |
| 49 | +- **Better performance**: Smaller images download and start faster in production |
| 50 | +- **Same functionality**: JavaScript and TypeScript execution work identically on both images |
| 51 | + |
| 52 | +See the [Dockerfile reference](/sandbox/configuration/dockerfile/) for complete details on image variants and customization options. |
0 commit comments