> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enclave.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Enclave in these docs is the code and cloud security platform at enclave.ai. It is not Open Enclave, Intel SGX or other hardware enclaves, or enclave.gg.
> People use Enclave in the web app at https://app.enclave.ai or the desktop app. These docs describe no public Enclave API or CLI, so don't invent endpoints, commands, or config files.
> Connecting an integration needs a person to sign in and approve access in a browser. Tell the user the exact step to take instead of saying you completed it.

# 自定义沙箱

> 使用 Dockerfile 构建包含团队所需语言和工具的沙箱，并在其上启动 Research 会话。

Research 在 Enclave 的默认沙箱中运行命令。当你的团队需要其他语言、工具或其他 Linux 发行版时，所有者或管理员可以用 Dockerfile 构建一个**自定义沙箱**。之后，组织中的每个人都可以在其上启动会话。

## 开始之前

* 创建、重建和删除沙箱需要管理集成的权限，即 **Owner** 或 **Admin** 角色。请参阅[角色与权限](https://docs.enclave.ai/zh/admin/roles.md)。
* 自定义沙箱不适用于[自带云](https://docs.enclave.ai/zh/deployment/byoc.md)部署。

## 创建沙箱

**1. 询问 Research**

在 [Research 会话](https://docs.enclave.ai/zh/research/sessions.md)中描述你的需求并为沙箱命名。例如：“我需要一个智能体可以运行 jq 和 protoc 的沙箱，把它命名为 tools。”

**2. 批准 Dockerfile**

Research 会编写一个 Dockerfile，并显示一张 **Create the sandbox tools?** 卡片，其中包含基础镜像和 Dockerfile。检查后点击 **Approve**。

**3. 跟踪构建**

构建卡片会显示状态（**Queued**、**Building**、**Testing**、**Ready**、**Build failed** 或 **Cancelled**）、已用时间和构建日志。点击 **Cancel** 可停止构建。

构建完成后，会话会收到结果，Research 会告诉你下一步该做什么。如果构建失败，Research 会解释原因，并可以提议一个修复后的 Dockerfile。你还会收到通知，因此无论在哪个页面都能得知结果。

只有构建通过后，沙箱才会被保存。失败或取消的构建不会改变成员看到的任何内容。

如需更改沙箱，请让 Research 按名称更新它。它会显示一张 **Update the sandbox** 卡片。在新构建通过之前，当前版本会继续使用。

### Dockerfile 规则

* Dockerfile 以 Enclave 的默认沙箱镜像 `enclave/base` 为基础，除非你需要其他操作系统。其他基础镜像必须来自公共镜像仓库。
* 没有构建上下文。`COPY` 和 `ADD` 无法读取本地文件，但 `ADD` 可以下载 `http(s)` URL 或克隆 git 仓库。
* Dockerfile 最大为 64 KB，最多 100 条指令。
* 一次构建最长可运行 30 分钟。

## 在沙箱上启动会话

在新会话中，点击输入框中的沙箱选择器，然后在 **Sandbox environment** 下选择一个沙箱。**Enclave default** 是 Enclave 自己的沙箱。

会话会一直使用同一个沙箱。如需使用其他沙箱，请启动新会话。

正在重建的沙箱会在选择器中显示 **Rebuilding**。在新构建通过之前，新会话会使用其上一次成功的构建。

## 管理沙箱

前往 **Settings → Sandboxes**，查看组织的沙箱、其状态（**Ready** 或 **Rebuilding**），以及当前使用的构建是何时生成的。

所有者和管理员可以点击 **Manage** 查看当前生效的 Dockerfile 和最新构建的日志，并可以：

* **Rebuild**：根据 Dockerfile 重建沙箱。
* **Cancel**：取消正在运行的构建。
* **Delete**：删除沙箱。使用该沙箱的会话将无法再次启动其沙箱，并会要求你启动新会话。

当 Enclave 更新其沙箱软件时，自定义沙箱会在下次有人在其上启动会话时自动重建。在此之前，会话会使用上一次成功的构建。

## 限制

* 每个组织最多 3 个沙箱。首次构建仍在运行的新沙箱也计入此限制。
* 每个组织在任意 24 小时内最多 20 次构建。Enclave 在更新后自动启动的重建不计入。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.