


















@@ -279,6 +279,100 @@ If you use your own Compose file or `docker run` command, add the same host
279279mapping yourself, for example
280280`--add-host=host.docker.internal:host-gateway`.
281281282+### Claude CLI backend in Docker
283+284+The official OpenClaw Docker image does not pre-install Claude Code. Install and
285+log in to Claude Code inside the container user that runs OpenClaw, then persist
286+that container home so image upgrades do not erase the binary or Claude auth
287+state.
288+289+For new Docker installs, enable a persistent `/home/node` volume before running
290+setup:
291+292+```bash
293+export OPENCLAW_IMAGE="ghcr.io/openclaw/openclaw:latest"
294+export OPENCLAW_HOME_VOLUME="openclaw_home"
295+./scripts/docker/setup.sh
296+```
297+298+For an existing Docker install, stop the stack first and reload the current
299+Docker `.env` values before rerunning setup. The setup script does not read
300+`.env` on its own; it rewrites `.env` from the current shell and defaults. For
301+the generated `.env`, run:
302+303+```bash
304+set -a
305+. ./.env
306+set +a
307+export OPENCLAW_HOME_VOLUME="${OPENCLAW_HOME_VOLUME:-openclaw_home}"
308+./scripts/docker/setup.sh
309+```
310+311+If your `.env` contains values your shell cannot source, manually re-export the
312+existing values you rely on first, such as `OPENCLAW_IMAGE`, ports, bind mode,
313+custom paths, `OPENCLAW_EXTRA_MOUNTS`, sandbox, and skip-onboarding settings.
314+The generated overlay mounts the home volume for both `openclaw-gateway` and
315+`openclaw-cli`.
316+317+Run the remaining commands with the generated Compose overlay so both services
318+mount the persisted home. If your setup also uses `docker-compose.override.yml`,
319+include it before `docker-compose.extra.yml`.
320+321+Install Claude Code in that persisted home:
322+323+```bash
324+docker compose -f docker-compose.yml -f docker-compose.extra.yml run --rm \
325+ --entrypoint sh openclaw-cli -lc \
326+'curl -fsSL https://claude.ai/install.sh | bash'
327+```
328+329+The native installer writes the `claude` binary under
330+`/home/node/.local/bin/claude`. Tell OpenClaw to use that container path:
331+332+```bash
333+docker compose -f docker-compose.yml -f docker-compose.extra.yml run --rm \
334+ openclaw-cli config set \
335+ agents.defaults.cliBackends.claude-cli.command \
336+ /home/node/.local/bin/claude
337+```
338+339+Log in and verify from inside the same persisted container home:
340+341+```bash
342+docker compose -f docker-compose.yml -f docker-compose.extra.yml run --rm \
343+ --entrypoint /home/node/.local/bin/claude openclaw-cli auth login
344+docker compose -f docker-compose.yml -f docker-compose.extra.yml run --rm \
345+ --entrypoint /home/node/.local/bin/claude openclaw-cli auth status --text
346+docker compose -f docker-compose.yml -f docker-compose.extra.yml run --rm \
347+ openclaw-cli models auth login \
348+ --provider anthropic --method cli --set-default
349+docker compose -f docker-compose.yml -f docker-compose.extra.yml run --rm \
350+ openclaw-cli models list --provider anthropic
351+```
352+353+After that, you can use the bundled `claude-cli` backend:
354+355+```bash
356+docker compose -f docker-compose.yml -f docker-compose.extra.yml run --rm \
357+ openclaw-cli agent \
358+ --agent main \
359+ --model claude-cli/claude-sonnet-4-6 \
360+ --message "Say hello from Docker Claude CLI"
361+```
362+363+`OPENCLAW_HOME_VOLUME` persists the native Claude Code install under
364+`/home/node/.local/bin` and `/home/node/.local/share/claude`, plus Claude Code
365+settings and auth state under `/home/node/.claude` and `/home/node/.claude.json`.
366+Persisting only `/home/node/.openclaw` is not enough for Claude CLI reuse. If
367+you use `OPENCLAW_EXTRA_MOUNTS` instead of a home volume, mount all of those
368+Claude paths into both Docker services.
369+370+<Note>
371+For shared production automation or predictable Anthropic billing, prefer the
372+Anthropic API-key path. Claude CLI reuse follows Claude Code's installed
373+version, account login, billing, and update behavior.
374+</Note>
375+282376### Bonjour / mDNS
283377284378Docker bridge networking usually does not forward Bonjour/mDNS multicast
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。