Skip to main content

Prerequisites

Before you begin, make sure you have:
  • Docker installed and running (verify with docker info)
  • Bun or Node.js 18+ installed

Installation

Install isol8 as a project dependency:
npm install isol8
To use the CLI globally, install it as a global package:
npm install -g isol8
If you prefer not to install globally, you can run the CLI directly via your package manager’s runner:
bunx isol8 <command>   # Bun
npx isol8 <command>    # npm
pnpx isol8 <command>   # pnpm

Build Docker Images

Before running any code, you need to build the isol8 runtime images. Run the setup command:
isol8 setup
This command performs two steps:
  1. Checks Docker connectivity — verifies the Docker daemon is reachable.
  2. Builds 5 base images — one per supported runtime:
    • isol8:python — Python 3.x with pip
    • isol8:node — Node.js LTS with npm
    • isol8:bun — Bun runtime with its built-in package manager
    • isol8:deno — Deno runtime with deno cache
    • isol8:bash — Alpine Linux with Bash and apk
You can also bake additional packages into the images during setup:
isol8 setup --python numpy,pandas --node lodash,express
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.

Execution Flow

The following diagram shows what happens when you submit code for execution:

Run Your First Code

Inline code — pass code directly with -e:
# Python (default runtime for inline code)
isol8 run -e "print('Hello from isol8!')"

# Explicit runtime
isol8 run -e "console.log('Hello from Node.js')" --runtime node

# Bash
isol8 run -e "echo 'Hello from Bash'" --runtime bash
Run a file — runtime is auto-detected from the file extension:
isol8 run script.py
isol8 run app.js
isol8 run index.ts      # Resolves to Bun
isol8 run handler.mts   # Resolves to Deno
isol8 run deploy.sh
Install packages on the fly:
isol8 run -e "import numpy as np; print(np.array([1,2,3]))" \
  --runtime python --install numpy

isol8 run -e "const _ = require('lodash'); console.log(_.chunk([1,2,3,4,5,6], 2))" \
  --runtime node --install lodash
Pipe stdin:
echo '{"name": "isol8"}' | isol8 run -e "import sys, json; print(json.load(sys.stdin)['name'])" --runtime python

Execution Modes

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
# CLI (ephemeral is the default)
isol8 run -e "print('each run is isolated')" --runtime python
// Library (ephemeral is the default)
const isol8 = new DockerIsol8(); // mode defaults to "ephemeral"
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
# CLI — use the --persistent flag
isol8 run --persistent -e "echo 'data' > /sandbox/state.txt" --runtime bash
isol8 run --persistent -e "cat /sandbox/state.txt" --runtime bash
// 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.

Next Steps