#15791: Docker: load buildx image and reuse gateway token
docker
stale
size: S
Cluster:
Docker and Deployment Improvements
This PR fixes Docker setup failures when Buildx uses the `docker-container` driver and the built image is not loaded into the local Docker image store. Also adds a safety fallback: if `buildx --load` is available but fails in the local environment, setup automatically retries with plain docker build instead of aborting.
Without `--load`, `docker compose run` may fail with:
`✘ openclaw-cli Error pull access denied for openclaw, repository does not exist or may require 'docker login': denied: requested access to the resource is denied`
## Summary
- use `docker buildx build --load` (when Buildx is available) so `openclaw:local` is usable by `docker compose run`
- prevent gateway token drift by reusing `~/.openclaw/openclaw.json` token when present
- keep existing fallback token generation behavior when no configured token exists
## Why
- Buildx with `docker-container` driver can complete builds but keep output only in build cache unless explicitly loaded/pushed.
- Re-running `docker-setup.sh` could generate a new token in `.env`, diverging from configured token and causing auth/pairing failures.
## Validation
- `bash -n docker-setup.sh`
- manual verification of token-source selection and Buildx output mode handling
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This change updates `docker-setup.sh` to (1) prefer `docker buildx build --load` when Buildx is available so `openclaw:local` is present in the local image store for `docker compose run`, and (2) reuse an existing gateway token from `~/.openclaw/openclaw.json` when `OPENCLAW_GATEWAY_TOKEN` isn’t already set, reducing token drift between config and `.env`.
The script still writes the chosen token into `.env` via `upsert_env`, and then uses Compose to run interactive onboarding and start the gateway container.
<h3>Confidence Score: 3/5</h3>
- Moderately safe to merge, but a couple of environment-dependent failures are possible
- The PR is small and focused, but it introduces additional reliance on `python3` in a script that already tries to support minimal environments, and the buildx switch is based on presence rather than capability/success. These can cause setup failures on systems where the previous behavior worked.
- docker-setup.sh
<sub>Last reviewed commit: c04c153</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#9999: Docker: fix token mismatch and add dev setup workflow
by benclarkeio · 2026-02-06
84.5%
#7133: feat: Automated Docker setup with environment-based configuration
by synetalsolutions · 2026-02-02
81.0%
#23313: feat(docker): add optional build-arg OPENCLAW_INSTALL_DOCKER_CLI to...
by zhuxuwei88-bot · 2026-02-22
80.9%
#22662: fix: use OPENCLAW_GATEWAY_TOKEN env var in onboard QuickStart
by aiworks451 · 2026-02-21
80.7%
#9190: feat(docker): Add autonomous container self-restart and runtime pac...
by alexdredmon · 2026-02-05
80.6%
#6698: feat: Add CLI wrapper for Docker integration and update documentation
by barshopen · 2026-02-01
79.7%
#12504: fix: allow docker cli container to connect to gateway
by bvanderdrift · 2026-02-09
79.5%
#6638: fix: make Dockerfile work on container platforms (Render, Railway, ...
by kaizen403 · 2026-02-01
79.2%
#8478: Security: remove --allow-unconfigured from default Dockerfile CMD
by uttej-badwane · 2026-02-04
79.2%
#8050: fix: docker hardening
by christopherbarnett96 · 2026-02-03
78.8%