Loading...
Loading...
Compare original and translation side by side
For full documentation, see the isol8 docs. This file is a quick-reference for AI agents — it covers the most common operations and links to detailed docs for everything else.
完整文档请查看 isol8 docs。本文档是AI Agent的快速参考指南——涵盖最常用操作,并链接到其他所有内容的详细文档。
| Command | Purpose | Full Docs |
|---|---|---|
| Execute code in an isolated container | CLI: run |
| Build Docker images, optionally bake in packages | CLI: setup |
| Remove orphaned isol8 containers | CLI: cleanup |
| Start HTTP server for remote execution (requires Bun) | CLI: serve |
| Display resolved configuration | CLI: config |
| 命令 | 用途 | 完整文档 |
|---|---|---|
| 在隔离容器中执行代码 | CLI: run |
| 构建Docker镜像,可选择性预装包 | CLI: setup |
| 移除孤立的isol8容器 | CLI: cleanup |
| 启动HTTP服务器用于远程执行(需要Bun) | CLI: serve |
| 显示已解析的配置 | CLI: config |
isol8 runisol8 run--evalpython--runtimepython.py.js.ts.mts.sh--evalpython--runtimepython.py.js.ts.mts.shisol8 runisol8 run| Flag | Default | Description |
|---|---|---|
| — | Execute inline code |
| auto-detect | Force: |
| | Keep container alive between runs |
| — | Install package before execution (repeatable) |
| | Network: |
| | Execution timeout |
| | Memory limit |
| — | Secret env var, value masked in output (repeatable) |
| — | Pipe data to stdin |
| 参数 | 默认值 | 描述 |
|---|---|---|
| — | 执行单行代码 |
| 自动检测 | 强制指定: |
| | 在多次运行之间保持容器存活 |
| — | 执行前安装包(可重复使用) |
| | 网络模式: |
| | 执行超时时间 |
| | 内存限制 |
| — | 敏感环境变量,值在输出中会被掩码(可重复使用) |
| — | 将数据通过标准输入传入 |
undefinedundefinedundefinedundefinedimport { DockerIsol8 } from "isol8";
const isol8 = new DockerIsol8({
mode: "ephemeral", // or "persistent"
network: "none", // or "host" or "filtered"
memoryLimit: "512m",
cpuLimit: 1.0,
timeoutMs: 30000,
secrets: {}, // values masked in output
});
await isol8.start();
const result = await isol8.execute({
code: 'print("hello")',
runtime: "python",
installPackages: ["numpy"], // optional
});
console.log(result.stdout); // captured output
console.log(result.exitCode); // 0 = success
console.log(result.durationMs);
await isol8.stop();import { DockerIsol8 } from "isol8";
const isol8 = new DockerIsol8({
mode: "ephemeral", // or "persistent"
network: "none", // or "host" or "filtered"
memoryLimit: "512m",
cpuLimit: 1.0,
timeoutMs: 30000,
secrets: {}, // values masked in output
});
await isol8.start();
const result = await isol8.execute({
code: 'print("hello")',
runtime: "python",
installPackages: ["numpy"], // optional
});
console.log(result.stdout); // captured output
console.log(result.exitCode); // 0 = success
console.log(result.durationMs);
await isol8.stop();import { RemoteIsol8 } from "isol8";
const isol8 = new RemoteIsol8(
{ host: "http://localhost:3000", apiKey: "secret" },
{ network: "none" }
);
await isol8.start();
const result = await isol8.execute({ code: "print(1)", runtime: "python" });
await isol8.stop();import { RemoteIsol8 } from "isol8";
const isol8 = new RemoteIsol8(
{ host: "http://localhost:3000", apiKey: "secret" },
{ network: "none" }
);
await isol8.start();
const result = await isol8.execute({ code: "print(1)", runtime: "python" });
await isol8.stop();for await (const event of isol8.executeStream({
code: 'for i in range(5): print(i)',
runtime: "python",
})) {
if (event.type === "stdout") process.stdout.write(event.data);
if (event.type === "exit") console.log("Exit code:", event.data);
}for await (const event of isol8.executeStream({
code: 'for i in range(5): print(i)',
runtime: "python",
})) {
if (event.type === "stdout") process.stdout.write(event.data);
if (event.type === "exit") console.log("Exit code:", event.data);
}await isol8.putFile("/sandbox/data.csv", "col1,col2\n1,2");
const buf = await isol8.getFile("/sandbox/output.txt");await isol8.putFile("/sandbox/data.csv", "col1,col2\n1,2");
const buf = await isol8.getFile("/sandbox/output.txt");| Method | Path | Auth | Description |
|---|---|---|---|
| | No | Health check |
| | Yes | Execute code, return result |
| | Yes | Execute code, SSE stream |
| | Yes | Upload file (base64) |
| | Yes | Download file (base64) |
| | Yes | Destroy persistent session |
| 方法 | 路径 | 认证 | 描述 |
|---|---|---|---|
| | 否 | 健康检查 |
| | 是 | 执行代码,返回结果 |
| | 是 | 执行代码,使用SSE流式返回 |
| | 是 | 上传文件(base64格式) |
| | 是 | 下载文件(base64格式) |
| | 是 | 销毁持久化会话 |
./isol8.config.json~/.isol8/config.json./isol8.config.json~/.isol8/config.json| Layer | Default |
|---|---|
| Filesystem | Read-only root, |
| Processes | PID limit 64, |
| Resources | 1 CPU, 512MB memory, 30s timeout |
| Network | Disabled ( |
| Output | Truncated at 1MB, secrets masked |
/sandbox.so/tmp| 层级 | 默认值 |
|---|---|
| 文件系统 | 只读根目录, |
| 进程 | PID限制64,启用 |
| 资源 | 1核CPU,512MB内存,30秒超时 |
| 网络 | 禁用( |
| 输出 | 截断至1MB,敏感信息掩码 |
/sandbox.so/tmpisol8 setup--timeout--memory--sandbox-size--tmp-size--sandbox-size.ts.ts--runtime deno.mtsbun run src/cli.ts serveisol8 setup--timeout--memory--sandbox-size--tmp-size--sandbox-size.ts.ts--runtime deno.mtsbun run src/cli.ts serve