Skip to content

feat(sandbox): replace one-shot docker run with session-scoped containers - #2769

Open
lyingbug wants to merge 1 commit into
Tencent:mainfrom
lyingbug:docker-sandbox
Open

feat(sandbox): replace one-shot docker run with session-scoped containers#2769
lyingbug wants to merge 1 commit into
Tencent:mainfrom
lyingbug:docker-sandbox

Conversation

@lyingbug

Copy link
Copy Markdown
Collaborator

Summary

  • Rework the Docker sandbox backend from one-shot docker run --rm into a RemoteSandboxClient: one long-lived container per session, so shell_exec, attachments, and artifact collection match Cube/E2B.
  • Exec wraps the process with timeout(1) so client cancel actually kills in-container work; files go through the Engine archive API; idle containers are reaped from an activity-marker mtime.
  • Settings grow daemon host / TLS / CPU / memory / PID / network / idle TTL fields. An empty host follows the local Docker CLI (DOCKER_HOST, then the current docker context) so Colima and Docker Desktop work without pasting a socket path. Remote tcp:// daemons require TLS; host / container: network modes are rejected.
  • Standard image now includes curl (egress check) and creates containers with root PID 1 so the activity marker is writable under USER user. Image pulls are no longer killed by the 30s HTTP client timeout.

Test plan

  • Settings → add a Docker backend, leave daemon address empty, run the connection check on a host where docker ps works (Linux socket, Colima, or Docker Desktop)
  • Rebuild wechatopenai/weknora-sandbox:latest from docker/Dockerfile.sandbox and confirm deep check (including egress) passes
  • Start a session, shell_exec twice, confirm packages/files survive; wait past idle TTL and confirm the container is reclaimed
  • Cancel a long-running exec and confirm the in-container process is gone
  • Saving a tcp:// host without a TLS cert directory is rejected; network_mode=host is rejected
  • go test ./internal/sandbox/ ./internal/handler/
  • Optional: go test -tags=docker_integration ./internal/sandbox/ against a reachable daemon

将 Docker 沙箱后端从一次性 exec 容器改为会话级长驻容器,使其会话与文件
系统语义与 E2B / Cube 后端对齐:

- 新增 docker_engine / docker_remote_client / docker_rpc_timeout,直连
  Docker Engine API,支持 TCP+TLS 远程守护进程,并为拉镜像等慢操作单独
  设置超时;daemon 地址留空时跟随本机 docker context。
- 新增空闲清理器 docker_idle_sweeper,按 exec 刷新的活跃标记回收长驻
  容器;标记文件对沙箱非 root 账号可写。
- 会话容器补 PID1 以回收僵尸进程;标准镜像补入 curl。
- 镜像即模板:docker_template_catalog 只上报可识别的沙箱镜像,标准模板
  的拉取在后台进行并报告 building。
- 设置页与租户配置支持守护进程地址、TLS 与 CPU/内存限额,四种语言文案
  同步;沙箱健康检查覆盖 Docker 后端。
- 补充 docs/sandbox-docker-backend.md 与 POC,说明能力边界与快照语义;
  git 钩子的变更包检测跳过嵌套 module,避免拿 POC 的包去跑主 module 测试。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant