/ 目錄 / 演練場 / Container Use
● 官方 dagger ⚡ 即開即用

Container Use

作者 dagger · dagger/container-use

Isolated, parallel containerized environments for coding agents.

Container Use gives every coding agent its own ephemeral container — so multiple Claude sessions can build, test, and run the same repo at the same time without stepping on each other. Built on Dagger; each environment has its own filesystem, branch, and process tree.

為什麼要用

核心特性

即時演示

實際使用效果

container-use-mcp.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "container-use-mcp": {
      "command": "cu",
      "args": [
        "mcp"
      ]
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "container-use-mcp": {
      "command": "cu",
      "args": [
        "mcp"
      ]
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "container-use-mcp": {
      "command": "cu",
      "args": [
        "mcp"
      ]
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "container-use-mcp": {
      "command": "cu",
      "args": [
        "mcp"
      ]
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "container-use-mcp",
      "command": "cu",
      "args": [
        "mcp"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "container-use-mcp": {
      "command": {
        "path": "cu",
        "args": [
          "mcp"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add container-use-mcp -- cu mcp

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: Container Use

Try three refactoring approaches in parallel, keep the best

👤 Engineers exploring design space ⏱ ~15 min intermediate

何時使用: You have 3 different ideas for a refactor and want to see all of them run/pass tests before picking one.

前置條件
  • Server/skill installed and authenticated — See repo README
步驟
  1. Spin up three isolated envs
    Create three container-use environments named refactor-a/b/c, all on this repo at HEAD.✓ 已複製
    → Three env_ids printed
  2. Apply each approach in its own env
    In refactor-a do the strategy-pattern version; in -b inline everything; in -c extract a service object. Run the full test suite in each. Report pass/fail and diff size.✓ 已複製
    → Per-env test summary and diff stats
  3. Pick the winner and merge
    Apply the diff from refactor-b to my working copy. Discard the other two environments.✓ 已複製
    → Patch applied locally

結果: Three real experiments evaluated side-by-side without ever breaking your host repo.

注意事項
  • Forgetting to discard old envs leaks disk — Forgetting to discard old envs leaks disk — cu environment list then cu environment discard <id> periodically.
搭配使用: github · filesystem

組合

與其他 MCP 搭配,撬動十倍槓桿

container-use-mcp + github

Pair with github for complementary capabilities

Use this server together with github to complete a multi-step task.✓ 已複製
container-use-mcp + filesystem

Pair with filesystem for complementary capabilities

Use this server together with filesystem to complete a multi-step task.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
environment_create name: str, image: str Start a fresh sandbox for the next task Local CPU/disk
environment_run_cmd env_id, cmd Execute build/test commands inside the sandbox free
environment_file_write env_id, path, contents Apply edits without touching the host free
environment_diff env_id Review the agent's work before merging back free

成本與限制

運行它的成本

API 配額
See provider docs for rate limits
每次呼叫 Token 數
Varies by tool
費用
See repo README for pricing details
提示
Cache tool results and avoid repeated identical calls.

安全

權限、密鑰、影響範圍

憑證儲存: Use environment variables; never commit secrets
資料出站: Tool calls go to the provider's API as documented

故障排查

常見錯誤與修復

docker daemon not running

Container Use requires a local Docker or compatible runtime. Start Docker Desktop or colima.

驗證: Run `docker ps` successfully
out of disk

Old environments aren't auto-pruned. Run cu environment list then cu environment discard <id> for anything older than a day.

驗證: Check `docker system df`

替代方案

Container Use 對比其他方案

替代方案何時用它替代權衡
Dagger CloudYou want hosted, multi-tenant agent envsPaid; container-use is local-first

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills