These packages are pre-installed in custom images (isol8:python-custom, etc.) so they’re available instantly at execution time without per-run install overhead.
# Python (default runtime for inline code)isol8 run -e "print('Hello from isol8!')"# Explicit runtimeisol8 run -e "console.log('Hello from Node.js')" --runtime node# Bashisol8 run -e "echo 'Hello from Bash'" --runtime bash
Run a file — runtime is auto-detected from the file extension:
Copy
isol8 run script.pyisol8 run app.jsisol8 run index.ts # Resolves to Bunisol8 run handler.mts # Resolves to Denoisol8 run deploy.sh
Install packages on the fly:
Copy
isol8 run -e "import numpy as np; print(np.array([1,2,3]))" \ --runtime python --install numpyisol8 run -e "const _ = require('lodash'); console.log(_.chunk([1,2,3,4,5,6], 2))" \ --runtime node --install lodash
In ephemeral mode, each execution acquires a fresh container from the warm pool. The code runs, output is collected, and the container’s /sandbox directory is wiped clean before being returned to the pool for reuse.Key characteristics:
No state persists between executions
Fastest startup thanks to the warm container pool (~55-95ms)
Most secure — every run starts with a clean slate
Ideal for one-off code execution, AI agent tool calls, and untrusted user code
Copy
# CLI (ephemeral is the default)isol8 run -e "print('each run is isolated')" --runtime python
Copy
// Library (ephemeral is the default)const isol8 = new DockerIsol8(); // mode defaults to "ephemeral"
Persistent
In persistent mode, a single container is kept alive across multiple execute() calls. Files, installed packages, environment variables, and all filesystem state persist between runs.Key characteristics:
State persists between executions (files, packages, environment)
Container stays alive until stop() is called or the idle timeout is reached
Supports putFile() and getFile() for direct file transfer
Ideal for multi-step workflows, REPL-like sessions, and iterative development
Copy
# CLI — use the --persistent flagisol8 run --persistent -e "echo 'data' > /sandbox/state.txt" --runtime bashisol8 run --persistent -e "cat /sandbox/state.txt" --runtime bash
Copy
// Library — set mode to "persistent"const isol8 = new DockerIsol8({ mode: "persistent" });await isol8.start();await isol8.execute({ code: 'open("/sandbox/data.txt", "w").write("persistent state")', runtime: "python",});const result = await isol8.execute({ code: 'print(open("/sandbox/data.txt").read())', runtime: "python",});console.log(result.stdout); // "persistent state"await isol8.stop();
In persistent mode, each container is locked to one runtime. Once a container is created with a specific runtime (e.g., Python), attempting to execute with a different runtime (e.g., Node.js) on the same DockerIsol8 instance will throw an error. Create a separate DockerIsol8 instance for each runtime you need.