Root cause of '容器里看不到任何 SK':
- Container's /root/.claude was an isolated named volume (empty)
- Host plugins live in ~/.claude/plugins/cache/<marketplace>/<plugin>/<version>/
- installed_plugins.json embeds ABSOLUTE paths like /Users/$USER/.claude/...
which don't resolve in container
Fix:
1. docker-compose.yml
- Bind-mount ${HOME}/.claude/plugins -> /root/.claude/plugins (ro)
- Bind-mount ${HOME}/.claude/skills -> /root/.claude/skills (ro)
- Pass HOST_HOME env var
2. scripts/container-entrypoint.sh (new)
- If HOST_HOME != HOME, symlink HOST_HOME -> /root so the absolute
paths inside installed_plugins.json resolve (e.g.
/Users/gongzhiyong/.claude/... -> /root/.claude/...)
3. Dockerfile
- Install entrypoint, wire it into ENTRYPOINT via tini
Verified: all 4 installed plugins (oh-my-claudecode, superpowers,
frontend-design, planning-with-files) + 3 skills (agent-browser,
find-skills, omc-reference) visible in container.
19 lines
665 B
Bash
Executable File
19 lines
665 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# 容器启动时运行的初始化脚本:
|
|
# 1) 如果 HOST_HOME 被传入且与 $HOME 不同,建立 symlink 让绝对路径兼容
|
|
# (例:宿主机 /Users/alice/.claude 里的 installed_plugins.json 含
|
|
# 绝对路径 /Users/alice/.claude/plugins/cache/... —— 需要容器里
|
|
# /Users/alice 也能解析到 /root,否则插件加载失败)
|
|
# 2) 最后 exec 真实命令
|
|
set -euo pipefail
|
|
|
|
if [[ -n "${HOST_HOME:-}" && "$HOST_HOME" != "$HOME" && "$HOST_HOME" != "/" ]]; then
|
|
if [[ ! -e "$HOST_HOME" ]]; then
|
|
parent=$(dirname "$HOST_HOME")
|
|
mkdir -p "$parent"
|
|
ln -sfn "$HOME" "$HOST_HOME"
|
|
fi
|
|
fi
|
|
|
|
exec "$@"
|