How to compile Docker on Windows

Yes, it's finally here!

Ahmet Alp Balkan
, on

After taking on my new role at the Azure Linux Team, my first assignment was to get the Docker command line interface working on Windows. This is an important piece in bringing Docker into the Windows ecosystem and part of our partnership with Docker.

Today, I am proud to announce that the first piece of Windows code is now merged into Docker, which means you can now compile the Docker client on Windows!

Before going any further, I would like to clarify several things:

Clarifications

Step 1: Install Go & Git

Download the Go MSI Installer from golang.org. This installation will add the go program to your PATH environment variable.

You also need to install Git for Windows because it brings a nice Unix shell emulator to your Windows machine. We will be using “Git Bash” installed with this.

Step 2: Compile!

The rest is just as simple. Launch Git Bash which you have just installed and run the following commands in the following order:

git clone --depth 1 https://github.com/docker/docker.git /c/gopath/src/github.com/docker/docker
cd /c/gopath/src/github.com/docker/docker
export GOPATH=/c/gopath:/c/gopath/src/github.com/docker/docker/vendor
export DOCKER_CLIENTONLY=1
chmod +x hack/make/.go-autogen && hack/make/.go-autogen
cd docker
go build

If all goes well, you will end up with a lovely docker.exe on the directory you are at! ♥ Here is a GIF screencast of this:

Summary

This is just an intro to building the Docker CLI for Windows. Normally, these binaries are built in a Linux environment, inside a Docker container (yes, Go is crazy like that, it can cross compile Windows binaries on Linux)! However, for demonstration purposes we are detailing the procedure for building these Windows binaries on its own turf.

In the meantime, you can use this tutorial to build Docker on your Windows machine to test the changes. We are looking forward to your contributions on making the Docker’s Windows support even better!

If you happen to find a bug, please open an issue on [Docker repo] and mention me cc: @ahmetalpbalkan in the description.

I would like to acknowledge help of the Docker developer community on getting this work reviewed and merged to Docker. We are looking forward to make it more stable and shippable soon!

There is some Windows code now living in Docker! ♥

(This article has appeared on Azure Blog, Docker Weekly, InfoQ, The Register.)


If you liked this post, you can follow me on Twitter or subscribe by email to my blog (no more than an article/month).