exec().
What you’ll build
A script that:- Runs Node.js code inside a
node:20-slimimage - Runs a shell script inside an
alpine:latestimage - Installs and uses CLI tools
- Runs multiple languages in the same box
Prerequisites
- Python
- Node.js
Step 1: Run Node.js code
Use thenode:20-slim image to run JavaScript inside a sandbox.
- Python
- Node.js
run_node.py
- SimpleBox pulls the
node:20-slimimage (cached after first use) exec("node", "-e", "...")runs the JavaScript code inside the VM- Output is captured in
result.stdoutjust like any other command
Step 2: Run a shell script
Usealpine:latest for a minimal environment, and run multi-line scripts with sh -c.
- Python
- Node.js
run_shell.py
Step 3: Install and run tools
Install packages inside the box using the image’s package manager, then use them.- Python
- Node.js
install_tools.py
Common images and package managers
Step 4: Mix languages in one box
Thenode:20-bookworm image includes both Node.js and Python 3, so you can combine languages in a single box without installing anything.
- Python
- Node.js
multi_language.py
Choosing the right image
What’s next?
Run services with port forwarding
Start HTTP servers, databases, or APIs inside a box and access them from the host.
Upload & download files
Copy files into the box, process them, and retrieve results.
Handle errors and debug
Catch exceptions, handle timeouts, and debug failures.
SimpleBox API reference
Full API docs for SimpleBox constructor options and methods.

