← Back to PRs

#23313: feat(docker): add optional build-arg OPENCLAW_INSTALL_DOCKER_CLI to install official docker-ce-cli

by zhuxuwei88-bot open 2026-02-22 06:11 View on GitHub →
docker size: XS
**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