OpenSandbox Code Interpreter Environment
English | 中文
This directory contains the Docker build files for the Code Interpreter sandbox. The image is based on Ubuntu 24.04 and comes pre-installed with multiple mainstream programming languages and their multi-version environments, designed to provide an out-of-the-box multi-language code execution environment.
Features
- Multi-Language Support: Pre-installed Python, Java, Node.js, and Go with multiple versions
- Version Switching: Easy runtime version switching without rebuilding
- Jupyter Integration: Built-in Jupyter Notebook with multi-language kernels
- Multi-Architecture: Supports both amd64 and arm64 architectures
- Production Ready: Optimized for containerized execution environments
Supported Languages & Versions
The image comes pre-installed with the following languages and versions:
| Language | Supported Versions | Installation Path | Notes |
|---|---|---|---|
| Python | 3.10, 3.11, 3.12, 3.13, 3.14* | /opt/python/versions | Installed via uv; 3.14 is experimental |
| Java | 8, 11, 17, 21 | /usr/lib/jvm | OpenJDK; includes Maven 3.9.2 |
| Node.js | v18, v20, v22 | /opt/node | Official Linux binaries |
| Go | 1.23, 1.24, 1.25 | /opt/go | Official Linux binaries |
> Note: Version numbers may be updated to the latest patch versions at build time.
Quick Start
1. Build the Image
Since multi-architecture (amd64/arm64) is supported, it's recommended to use Docker Buildx:
# Navigate to the directory
cd sandboxes/code-interpreter
# Build local image
docker build -t opensandbox/code-interpreter:latest .
# For multi-architecture builds (requires Docker Buildx)
docker buildx build --platform linux/amd64,linux/arm64 \
-t opensandbox/code-interpreter:latest .2. Run the Container
With Custom Version Selection:
docker run -it --rm \
-e PYTHON_VERSION=3.11 \
-e JAVA_VERSION=17 \
-e NODE_VERSION=20 \
-e GO_VERSION=1.24 \
opensandbox/code-interpreter:latestVersion Switching
The image includes a built-in version switching script /opt/opensandbox/code-interpreter-env.sh. You need to use the source command to load it to modify the current shell's environment variables.
Basic Usage
source /opt/opensandbox/code-interpreter-env.sh <language> <version>Examples
Switch Python Version:
# Switch to Python 3.11
source /opt/opensandbox/code-interpreter-env.sh python 3.11
python3 --version
# Output: Python 3.11.xSwitch Java Version:
# Switch to Java 8
source /opt/opensandbox/code-interpreter-env.sh java 8
java -versionSwitch Node.js Version:
# Switch to Node 22
source /opt/opensandbox/code-interpreter-env.sh node 22
node -vSwitch Go Version:
# Switch to Go 1.25
source /opt/opensandbox/code-interpreter-env.sh go 1.25
go versionList Available Versions
If you don't specify a version number, the script will list all available versions installed in the current image:
# List all Python versions
source /opt/opensandbox/code-interpreter-env.sh python
# List all Java versions
source /opt/opensandbox/code-interpreter-env.sh java
# List all Node.js versions
source /opt/opensandbox/code-interpreter-env.sh node
# List all Go versions
source /opt/opensandbox/code-interpreter-env.sh goDefault Versions
The default version configuration when the container starts:
- Python: 3.14
- Java: 21
- Node.js: 22
- Go: 1.25
To permanently modify the default version at the Dockerfile level, adjust the ENV PATH settings at the bottom of the Dockerfile.
Jupyter Notebook Integration
Available Kernels
The image comes with pre-configured Jupyter kernels for all supported languages:
- Python: ipykernel for all Python versions
- Java: IJava kernel
- TypeScript/JavaScript: tslab kernel
- Go: gonb kernel
- Bash: bash_kernel
Starting Jupyter
/opt/opensandbox/code-interpreter.shEnvironment Variables
JUPYTER_HOST: Jupyter server host (default:http://127.0.0.1:44771)JUPYTER_PORT: Jupyter server port (default:44771)JUPYTER_TOKEN: Access token (default:opensandboxcodeinterpreterjupyter)
Advanced Usage
Persistent Workspace
Mount a local directory to persist your work:
docker run -it --rm \
-v $(pwd)/workspace:/workspace \
opensandbox/code-interpreter:latestCustom Configuration
Override Jupyter configuration:
docker run -it --rm \
-v $(pwd)/jupyter_config.py:/root/.jupyter/jupyter_notebook_config.py \
opensandbox/code-interpreter:latestInstall Additional Packages
Python:
python3 -m pip install pandas numpy --break-system-packagesNode.js:
npm install -g typescriptGo:
go install github.com/user/package@latestJava:
mvn install dependency:copy-dependenciesArchitecture
code-interpreter/
├── Dockerfile # Main build file
├── Dockerfile_base # Base build file
├── README.md # This file
├── README_zh.md # Chinese README
└── scripts/
├── code-interpreter-env.sh # Version switching script
├── code-interpreter.sh # Jupyter startup script
└── jupyter_notebook_config.py # Jupyter configurationTroubleshooting
If a specific version is not found, list available versions:
source /opt/opensandbox/code-interpreter-env.sh <language>License
This project is part of the OpenSandbox suite. See the main LICENSE file for details.
Support
For issues and questions:
- GitHub Issues: OpenSandbox Issues
Related Projects
- OpenSandbox - Main project
- Server - Server implementation
- Execd - Runtime execution engine
This page is sourced from:
sandboxes/code-interpreter/README.md