蚂蚁 inclusionAI 开源沙箱生命周期服务 sandboxd
inclusionAI/sandboxd
蚂蚁集团 inclusionAI 在 GitHub 开源 sandboxd,这是 AKernel 使用的 Linux 沙箱生命周期服务,通过 gRPC API 管理沙箱资源,当前基于 gVisor 运行沙箱,并计划近期开源 Kata Containers 支持。
蚂蚁把 AKernel 用的沙箱生命周期管理开源了,对需要安全执行代码的 AI 推理/评测场景有参考价值,但仅限底层基础设施人员,非目标受众不必深究。
sandboxd
sandboxd 是 AKernel 所使用的 Linux 沙箱生命周期服务。它对外暴露一组精简的 gRPC API,负责管理沙箱资源,目前使用 gVisor 运行沙箱。对 Kata Containers 的支持即将开源。
职责
- 启动、等待、检查、度量并删除沙箱。
- 准备本地、OCI、Nydus 以及 S3 后端的 rootfs 和挂载。
- 分配 cgroups(目前仅支持 v1)和 veth 接口,并为 NAT 配置 iptables。
架构
gRPC service
|
sandbox lifecycle manager
├── sandbox runtime adapter ──> gVisor
├── image manager ────────────> distill-fs / OCI
└── resource managers ────────> cgroup v1 / veth / iptables
API / CLI
公开的 protobuf 契约位于 api/runtime/v1/sandbox-api.proto。
sbox 二进制文件是用于管理沙箱的管理 CLI。
构建与测试
make
make test
make vet
特权 E2E 测试套件需要 Docker、cgroup v1、iptables 以及所测试的 runsc 版本:
RUNSC_BINARY=/usr/local/bin/runsc make e2e
开发者测试环境请参见 test/e2e/README.md。AKernel 集成通过 all-in-one 节点镜像以及 AKernel 仓库中的独立部署进行验证。
Protobuf 开发
Protobuf 生成使用由 Makefile 和 tools/protobuf.Dockerfile 定义的固定 Docker 镜像,不依赖宿主机安装的 protobuf 工具:
make protos
make check-protos
将生成的 Go 绑定与对应的 protobuf 变更一并提交。
项目结构
api/ public protobuf API and generated Go code
cmd/sandboxd/ sandboxd daemon
cmd/sbox/ administrative CLI
config/ configuration types and defaults
configs/ AKernel integration configuration templates
internal/server/ gRPC service and daemon orchestration
pkg/runtime/ sandbox runtime abstraction and gVisor adapter
pkg/imagemanager/ rootfs and mount integration
pkg/networkmanager/ veth and iptables integration
pkg/cgroupmanager/ cgroup v1 integration
test/e2e/ privileged runsc E2E
tools/ pinned protobuf code-generation image
已知限制
- 在
v0.1.0中仅支持 gVisor、cgroup v1、netstack 沙箱网络和 iptables。 - 直接 OCI registry 客户端目前会跳过 TLS 证书验证,因此只应与受信任的 registry 一起使用。
许可证
Copyright (c) 2026 Ant Group Corporation.
依据 Apache License, Version 2.0 授权。详见 LICENSE。第三方 Go 模块在 go.mod 中声明,并保留其各自的许可证。
来源:蚂蚁 inclusionAI:GitHub 新仓库 · github.com