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.
Who wants @Docker for Windows? Got it cross-compiling tonight!
🐳 cc:@solomonstre #docker pic.twitter.com/bGOn0jmX8m
— Ahmet Alp Balkan (@ahmetalpbalkan) October 28, 2014
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!
Spectacular work by @ahmetalpbalkan, opening Microsoft's 1st @docker PR: https://t.co/xwmj5jPBeJ
— Solomon Hykes (@solomonstre) November 12, 2014
Before going any further, I would like to clarify several things:
Clarifications
-
At this point, the merged code is only the first step in getting it compiling and (barely) working on Windows. We have a set of known bugs (see PR description), which we are looking forward to fix and I am pretty sure there are more bugs beyond that. Making something designed for UNIX work on Windows seamlessly is not a trivial task. In the upcoming days, I will be focusing on resolving those bugs. We are also looking forward to seeing your contributions to make Docker’s Windows support better.
-
Also, please note that this tutorial is not about running the Docker daemon on Windows or running Windows containers on Docker. None of these are possible today. This is just about getting client code compiled on Windows.
-
I will not be talking about how the porting work was done, that will be topic of another blog post here on my blog, again. Stay tuned for that one!
-
Please note that the docker.exe you are about to build is not a supported distribution by Microsoft or Docker. Please use it at your own risk. A more stable version of the Docker Windows CLI will be shipped later.
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!
We promised @docker client for Windows. The first pull request from @ahmetalpbalkan is ready. Want to help test it? https://t.co/t7AM123Pdg
— Ross Gardler (@rgardler) November 13, 2014
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.)
Leave your thoughts