Home > Back-end >  How to install docker client only without docker engine
How to install docker client only without docker engine

Time:10-18

I want to write a script which going to use docker API. It will communicate with the docker engine which runs on the host machine. I don't wanna install the entire docker to my image just CLI and later use the host network to communicate with the docker engine.

My script under the hood gonna run commands like docker image inspect someiamge

CodePudding user response:

You can use binary distribution of docker, which can be downloaded from here, you can get docker client binaries there.

Here is the documentation of installation of a docker from binaries. Just skip part of starting docker engine and make sure that your docker client points to a correct remote engine (mounting /var/run/docker.sock)

CodePudding user response:

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
  • Related