How to update Docker CLI client for Windows

Sometimes you need to update your Docker Client for Windows, which was installed with Docker Toolbox. But you can’t find an easy way to do that (see this thread for example).

Docker Toolbox is the legacy way to use Docker on Windows, using VirtualBox, but it’s still useful when :

Upgrading the Docker Engine (server side) is easy with docker-machine. Just use :

docker-machine upgrade <machine_name>

and it will try to download the latest release (boot2docker.iso, working on VirtualBox) on https://github.com/boot2docker/boot2docker/releases/latest .

To update Docker Client, you could reinstall Docker Toolbox, but it’s quite cumbersome. In fact you can rebuild docker.exe from sources. After Docker Toolbox installation, this file can normally be found in « C:\Program Files\Docker Toolbox\docker.exe« .

How to build an exe for Windows

I found in Docker Toolbox sources how docker.exe was built and embedded.
It’s partly in this line :

RUN cp /go/src/github.com/docker/cli/build/docker-windows-amd64 docker.exe

Then I found that the CLI tool is in this repo : https://github.com/docker/docker-ce, under components/cli . So we can follow the instructions to build it.

For example, if you want to build docker.exe for a given version, let’s say « 18.05.0-ce », you can follow this script :

Install the new exe

Then you can backup your old docker.exe in « C:\Program Files\Docker Toolbox\docker.exe » and replace it with the new one.

Test the new version

Check that the new version is working :

> docker --version
Docker version 18.05.0-ce, build
Publicités