I thinking about using docker image to extract the CLI client.
COPY --from=docker:latest /usr/local/bin/docker /usr/local/bin/
Example of dockerfile
FROM php:8-cli-alpine
COPY --from=docker:latest /usr/local/bin/docker /usr/local/bin/
And later you could use this image with following command
docker run -it --rm --entrypoint docker -v docker run -it --rm --entrypoint docker -v /var/run/docker.sock:/var/run/docker.sock yourimage:tag image ls
This has a significant downside. The docker image does not support linux/arm/v7
architecture.
=> ERROR [linux/arm/v7 internal] load metadata for docker.io/library/docker:latest 4.5s
=> ERROR [linux/arm/v7 internal] load metadata for docker.io/library/composer:2
Better to use SDK.