Is it possible to install only the docker cli and not the daemon
If you want to install Docker in Linux, then in the newest 1.12.0 release, Docker daemon and Docker client are in separate binary files.
This has been mentioned in release log:
Split the binary into two: docker (client) and dockerd (daemon) #20639
If you are installing Docker in Mac, then Mac OS binary is client-only: resource
First, download and unzip/untar the release for your system. Here are x86_64 binaries for mac, linux, windows.
After expanding the archive, you can find the docker CLI executable at ./docker/docker
- move that file into your path, and you're done.
If you're specifically looking to install the docker CLI into a docker image, here's my Dockerfile command to do so:
ENV DOCKERVERSION=18.03.1-ce
RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \
&& tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 \
-C /usr/local/bin docker/docker \
&& rm docker-${DOCKERVERSION}.tgz
h/t to this comment
You can (like the other answer suggests) download it direct from Docker:
docker_url=https://download.docker.com/linux/static/stable/x86_64
docker_version=18.03.1-ce
curl -fsSL $docker_url/docker-$docker_version.tgz | \
tar zxvf - --strip 1 -C /usr/bin docker/docker
The difference from the other answer is that there is no intermediate tar file. I use this in a Dockerfile RUN layer.
Adding to the approach from Aaron, if you're building your own image, you can now just use multi-stage builds to copy over the docker
binary from an existing external image, e.g.:
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/
This pulls the docker
binary from the public
docker:dind
image on Dockerhub.
See: https://docs.docker.com/develop/develop-images/multistage-build/.