#14061: fix(gateway): Docker CLI container gateway connectivity and auth
channel: discord
gateway
cli
scripts
docker
agents
stale
Cluster:
Docker and Deployment Improvements
## Summary
- **Docker DNS resolution**: Replace hardcoded `127.0.0.1` gateway host with `OPENCLAW_GATEWAY_HOST` env var across all connection points (TUI, call, client, agents, daemon CLI, discord, node host). Set `OPENCLAW_GATEWAY_HOST=openclaw-gateway` in `docker-compose.yml` so the CLI container resolves the gateway via Docker DNS.
- **Docker gateway IP verification**: Detect Docker environments via `/.dockerenv` and parse `/proc/net/route` to identify the container's default gateway IP. Only treat connections as local when the client IP matches the actual Docker bridge gateway, preventing Host header spoofing by other containers.
- **Device pairing auto-approval**: Auto-approve device pairing when the client authenticates with a valid shared secret (token/password), not just for loopback clients. This lets Docker CLI containers with `OPENCLAW_GATEWAY_TOKEN` connect without manual pairing.
- **Entry point fix**: Update `docker-compose.yml` and helper scripts to use `openclaw.mjs` instead of `dist/index.js`.
## Test plan
- [x] `docker compose run --rm openclaw-cli tui` connects and shows "device pairing auto-approved" in gateway logs
- [x] Gateway correctly rejects container-to-container spoofing (non-gateway IP + Host: localhost)
- [x] Unit tests pass for `isDockerEnvironment`, `readDockerGatewayIp`, and `isLocalDirectRequest` Docker paths
- [x] Non-Docker loopback connections still work as before
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Most Similar PRs
#9999: Docker: fix token mismatch and add dev setup workflow
by benclarkeio · 2026-02-06
74.9%
#6638: fix: make Dockerfile work on container platforms (Render, Railway, ...
by kaizen403 · 2026-02-01
74.4%
#21784: fix(security): restrict gateway ports to loopback by default
by smilekyra · 2026-02-20
74.1%
#12504: fix: allow docker cli container to connect to gateway
by bvanderdrift · 2026-02-09
73.5%
#3744: Gateway: fix device pairing when local connection retries with exis...
by photon3710 · 2026-01-29
70.0%
#8050: fix: docker hardening
by christopherbarnett96 · 2026-02-03
69.9%
#8478: Security: remove --allow-unconfigured from default Dockerfile CMD
by uttej-badwane · 2026-02-04
69.9%
#9190: feat(docker): Add autonomous container self-restart and runtime pac...
by alexdredmon · 2026-02-05
69.7%
#19644: feat(docker): add init script support via /openclaw-init.d/
by JayMishra-source · 2026-02-18
69.3%
#21741: fix(gateway): allow plaintext ws:// for Docker/private network addr...
by Joe3112 · 2026-02-20
69.0%