#23313: feat(docker): add optional build-arg OPENCLAW_INSTALL_DOCKER_CLI to install official docker-ce-cli
docker
size: XS
Cluster:
Docker Integration and Documentation
**Problem**
- Using `OPENCLAW_DOCKER_APT_PACKAGES="docker.io"` installs an outdated Docker CLI from Debian repos.
- This often causes compatibility issues with newer host Docker daemons (API version mismatch, "client too old" errors).
- `docker-ce-cli` cannot be installed via the existing arg because it requires adding Docker's official apt repository first.
**Solution**
- Introduces a new optional build-arg: `OPENCLAW_INSTALL_DOCKER_CLI=1`
- When set, adds Docker's official GPG key and apt source, then installs the latest `docker-ce-cli`.
- Keeps the image minimal by default (no installation if arg is not provided).
- Fully backward compatible with existing `OPENCLAW_DOCKER_APT_PACKAGES` usage.
**Usage example**
```bash
docker build --build-arg OPENCLAW_INSTALL_DOCKER_CLI=1 -t openclaw:latest .
Or in docker-compose.yml:
build:
context: ./openclaw-main
dockerfile: Dockerfile
args:
- OPENCLAW_INSTALL_DOCKER_CLI=1
Benefits
Ensures CLI version matches or exceeds host daemon
No need for manual Dockerfile hacks
Clear build logs with echo statements
Tested locally: docker version shows compatible Client version after build.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added optional build argument `OPENCLAW_INSTALL_DOCKER_CLI=1` to install official `docker-ce-cli` from Docker's apt repository, solving version mismatch issues when mounting `/var/run/docker.sock`.
- Follows Docker's official Debian installation procedure (GPG key + apt source)
- Opt-in only (default: no installation, keeps image minimal)
- Backward compatible with existing `OPENCLAW_DOCKER_APT_PACKAGES`
- Properly cleans up apt cache to minimize image size
- Hard-coded `bookworm` version matches the Node.js 22 base image
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation follows Docker's official installation guide, is opt-in only (doesn't affect default builds), properly handles cleanup, and is backward compatible. Only minor style issues with trailing whitespace were found.
- No files require special attention
<sub>Last reviewed commit: 1e6f831</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
#5866: feat: add optional Docker official repo APT source
by codearranger · 2026-02-01
87.1%
#7986: feature/OPENCLAW_IMAGE
by ozbillwang · 2026-02-03
85.8%
#6698: feat: Add CLI wrapper for Docker integration and update documentation
by barshopen · 2026-02-01
85.1%
#7133: feat: Automated Docker setup with environment-based configuration
by synetalsolutions · 2026-02-02
83.6%
#22491: Use multi-stage docker build to reduce image size from 4.72GB -> 2....
by mm-zacharydavison · 2026-02-21
83.4%
#22344: feat(docker): add pre-built image mode for docker-setup
by AIflow-Labs · 2026-02-21
83.3%
#9190: feat(docker): Add autonomous container self-restart and runtime pac...
by alexdredmon · 2026-02-05
82.1%
#4450: fix bug #4366: Error: Config validation failed: plugins.slots.memor...
by tryagain3 · 2026-01-30
81.4%
#15791: Docker: load buildx image and reuse gateway token
by ttulttul · 2026-02-13
80.9%
#17506: Fix Entrypoint in docker-compose
by NeilSCGH · 2026-02-15
80.6%