Building docker-machine The Easy Way

Recently, I needed to build docker-machine from source. In my case it was because
the 0.5.3 release (current stable release at the time I wrote this) had a glitch.
It output the results of a number of commands to STDERR instead of STDOUT.

Although this issue was fixed fairly quickly, I will leave this post up as it
may be useful someone some day.

All of docker including docker-machine is written in GO. I had learned from a
previous experiment (Influxdb on Raspberry Pi) that installing GO was not a small
project. A quick review of the contributing guild hinted at an easier way.

docker-machine can be built in a preconfigured docker container simply by setting
USE_CONTAINER=true.

You will need docker running. I ironically used the released version of
docker-machine to run a docker server. You will also need make and git (these are
optional if you want to download and extract the tarball).

The Code

# get the source into a directory called `machine`
# alternately, grab the tarball and extract (change paths as necessary)
git clone https://github.com/docker/machine.git

# build (may take a few minutes due to image download and configuration)
cd machine
export USE_CONTAINER=true
make build

# copy the resultant binary over the official one
sudo cp ./build/docker-machine /usr/local/bin/docker-machine

Code above was tested and ran successfully on an Ubuntu 15.04 system. If you have
any issues please leave a comment.

Leave a Reply