dsh-container-lifecycle:用 digest 鎖定的 Docker 容器承載 Profile 執行面

前言

在 DeepSeek Harness(DSH)裏,智能體的 shell、文件系統與沙箱默認跑在宿主進程側。若你希望命令與文件操作落在隔離的 Linux 環境裏,同時工作區仍能以同路徑掛載進會話,就需要把「執行世界」遷到容器裏,並自己管鏡像、SSH 通道與信任鏈。社區插件 dsh-container-lifecycle(維護者 FAKE0704,分類 admin-security)做這件事:把一個 Profile 轉成由插件端到端擁有的容器執行世界,上游 dsh-ssh 傳輸包不改、不做代理。

下文按定位、能力、安裝、用法與限制說明;事實以 GitHub README 與 SkillHub 目錄頁 爲準。插件標註爲 experimental(Stage A),獨立社區作品,未經 DeepSeek Harness 官方審閱或背書。

這是什麼

dsh-container-lifecycle 是 DSH 社區插件(MIT,0.1.0),engines.dsh 要求運行時 >=0.2.2-rc.2 <0.2.2-rc.3。它讓 Profile 的 shell、fs、sandbox 不再在宿主機上直接執行,而是在插件創建並管理的 Docker 容器內運行:鏡像按 digest 鎖定,容器帶標籤(sshd、同路徑 bind mount、僅迴環端口、宿主 uid 映射),helper 注入並做入口 SHA-256 校驗,臨時 host key 寫入插件自有的 known_hosts,並託管 ~/.ssh/config 塊,在運行時插入原版 dsh-ssh 連接行。不改動上游接縫,不代理流量。

核心功能

經過上面的定義,插件在資料中寫明的能力包括:

  1. 同路徑工作區:宿主路徑(例如 /Users/you/work)在容器內仍是同一路徑,便於工具與路徑假設一致。
  2. 重啓後可接納(adopt):容器帶標籤,宿主機重啓後可重新接納;臨時 host key 自動重新鎖定。
  3. 拒絕漂移的信任鏈:拉取或本地構建後按 digest(或本地 image ID)固定鏡像;同 tag 下重建的鏡像會被拒絕,並給出雙 digest 與顯式 rebind 路徑。helper 入口每次加載重新校驗;容器內安裝的 closure 與版本嚴格對齊。
  4. 首次自動構建:若鏡像 tag 不存在,插件用自帶的 docker/Dockerfile 構建(aptMirror 可配),並鎖定結果。
  5. 兩個只讀爲主工具:container-status(鏡像/容器/helper/ssh 塊等事實)、container-dispose(經審批門控的拆除)。
  6. 會話內驗證:README 中的實測顯示,bash/fs 在 Debian bookworm 容器內執行,而 pwd 仍可顯示宿主風格的掛載路徑——這是同路徑投影,不是跑在 macOS 宿主機上。

安裝與啓用

資料給出的已驗證路徑是無頭 CLI(macOS + Docker Desktop;DSH_HOME 默認 ~/.dsh)。先做 Profile 引導,再安裝插件。

1 — 引導名爲 headless 的 Profile(一次粘貼;聲明 bundles、構建姿態與模型接線):

mkdir -p "$DSH_HOME/profiles/headless" && cd "$DSH_HOME/profiles/headless"
cat > package.json <<'EOF'
{
  "name": "dsh-profile-headless",
  "private": true,
  "dependencies": {
    "dsh-container-lifecycle": "github:FAKE0704/dsh-container-lifecycle"
  },
  "dsh": { "profile": { "bundles": [
    "@deepseek-ai/dsh-base",
    "@deepseek-ai/dsh-headless",
    "dsh-container-lifecycle"
  ] } }
}
EOF
cat > pnpm-workspace.yaml <<'EOF'
packages:
  - .

nodeLinker: hoisted
autoInstallPeers: false
allowBuilds:
  node-pty: false
  koffi: false
  "@deepseek-ai/dsh-subprocess-local": false
EOF
cat > cordis.patch.yml <<'EOF'
# Model wiring: bring your own provider. The container world itself needs no
# profile rows — it comes from the plugin's own bundle patch.
- id: agent-default-model
  name: "@deepseek-ai/dsh-agent-default-model"
  config:
    provider: <your-provider>
    model: <your-model>
EOF

allowBuilds: false 是有意爲之:原生 helper 模塊(node-pty、koffi、dsh-subprocess-local)只在容器內構建,不在宿主機構建,否則 pnpm 11 可能把被阻斷的構建腳本當成安裝失敗。

2 — 安裝插件(README 原文命令):

dsh plugin --profile headless add dsh-container-lifecycle

若 git ls-remote 超時或 HTTP/2 異常,可按 README 建議改用 SSH URL 映射或強制 HTTP/1.1;驗證記錄約爲 2¼ 分鐘 exit 0。

3 — 在容器世界中跑會話:

cd /your/workspace && dsh --profile headless "uname -a && head -2 /etc/os-release"

首次啓動會構建鏡像(需可拉取 node:24-bookworm-slim 基礎鏡像)、創建容器、在容器內安裝 helper closure 並寫入 ssh 配置塊,耗時可到數分鐘,僅首次。

配置項

在 Profile 的 cordis.patch.yml 中按 id 覆蓋(默認值如下):

- id: dsh-container-lifecycle
  config:
    alias: dsh-container      # container name + ssh Host alias
    image: dsh-container-sshd:a1
    port: 2223                # loopback host port for sshd
    aptMirror: ""             # e.g. mirrors.tuna.tsinghua.edu.cn (first-use build only)
    workspace: ""             # default: process working directory (bind-mounted at the identical path)
    imageRebind: false        # one-shot deliberate re-pin after an intentional rebuild

端口衝突會以具名錯誤指出對應配置項。 intentional 重建鏡像後需將 imageRebind 設爲 true 一次以採納新 digest(容器會重建)。

典型用法與宿主限制

除上文的 uname / os-release 探測外,README 還給出了在 Electron/BoringSSL 無法承載 dsh-ssh 流時的變通:用自帶 plain-OpenSSL 的 Node 啓動無頭 CLI,而非 Desktop 的 Electron 載體:

node /path/to/extracted/dsh/node_modules/@deepseek-ai/dsh-desktop-host/lib/cli.js --profile headless "<task>"

須在真實終端啓動(勿在沙箱化的 DSH 會話內啓動,否則繼承沙箱會導致 ~/.ssh 寫入失敗)。

當前 README 寫明:DSH Desktop 與以其爲載體的 CLI 因 Electron BoringSSL 缺少 TLS 1.2 PSK 套件,容器世界會與任何 dsh-ssh 用法一樣降級;已驗證宿主爲 plain-OpenSSL Node 驅動的無頭 CLI。上游若補齊套件,Desktop 側無需改插件即可工作(參見 upstream discussion #9120)。

適用場景與注意

適合:需要在 digest 鎖定、可審計的信任鏈下,讓智能體工具在 Debian 容器內執行,同時保持工作區同路徑映射;願意使用 Docker,並接受 Stage A 實驗性質與窄版本釘扎(ssh 族 exact 0.2.2-rc.2)。

務必注意:

  • 插件以當前 dsh 進程權限運行,會寫 Docker、ssh 配置與 known_hosts;安裝前請閱讀源碼與 MIT 許可證。
  • 社區目錄 SkillHub 與 GitHub 爲獨立信息源,與 DeepSeek / 幻方無官方從屬關係。
  • 星標與受衆規模資料未作營銷表述;僅以 README 測試記錄(如 macOS arm64 + Docker Desktop、0.2.2-rc.1 / 0.2.2-rc.2)爲據。

結尾

dsh-container-lifecycle 把 Profile 的執行面收攏到插件自管的 digest 鎖定容器與未改動的 dsh-ssh 鏈路上,強調同路徑掛載與拒絕鏡像/helper 漂移。若你的環境滿足無頭 CLI + Docker,可按 README 三步引導 Profile、安裝插件並首次構建驗證。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜