Docker Machine - initial thoughts
December 15, 2014
docker
Last Friday I spent most of my day fiddling with 2 new Docker projects: Machine and Swarm. In this blog, I would like to share my findings and some thoughts about Machine and the problems it intends to solve.
Docker Machine
According to the Github repository, Docker Machine
… makes it really easy to create Docker hosts on local hypervisors and cloud providers. It creates servers, installs Docker on them, then configures the Docker client to talk to them.
Basically, the above pretty much sums up what Machine does. With a single command you can build a Docker host on your local machine or any cloud service of your choosing. It works somewhat like this:
$ machine create -d virtualbox dev
[info] Downloading boot2docker...
[info] Creating SSH key...
[info] Creating VirtualBox VM...
[info] Starting VirtualBox VM...
[info] Waiting for VM to start...
[info] "dev" has been created and is now the active host. Docker commands will now run against that host.
$ machine ls
NAME ACTIVE DRIVER STATE URL
dev * virtualbox Running tcp://192.168.99.100:2375
$ export DOCKER_HOST=`machine url` DOCKER_AUTH=identity
$ docker run busybox echo hello world
Unable to find image 'busybox' locally
Pulling repository busybox
e72ac664f4f0: Download complete
511136ea3c5a: Download complete
df7546f9f060: Download complete
e433a6c5b276: Download complete
hello world
Pretty easy, right? Well, there’s some small print at this point. Currently, only the Virtualbox and Digital Ocean providers actually work, and you need to use a patched version of Docker to make Machine work at all. Also, for each Docker host you build, Machine will download the boot2docker ISO, although you can supply your own ISO if you are brave enough to go through the process of patching the boot2docker ISO with the patched Docker version.
Mixed bag
Docker Machine has me puzzled a bit. Although it clearly aims at making it super easy to provision your own Docker hosts, I can’t see myself using it in its current form.
For development setups I might as well just use boot2docker or Vagrant, as both do what they need to, and are way more mature. Besides, Machine doesn’t seem to bring anything new to the table in that respect.
As for production setups, I can’t think of a reason anyone would want to use Machine for deploying Docker hosts. It simply ‘does too little’. For instance, it does not cover the configuration of DNS, NTP, Syslog, SELinux, authentication, sudo or even the hostname for a Docker host. It just installs Docker. At this moment, I would simply use Gareth Rushgrove’s Docker module for Puppet to setup my Docker hosts. This can be as simple as:
include docker
Or a little more advanced, like:
class mycompany_docker (
$docker_port = 2375,
$docker_bind = '0.0.0.0',
$docker_manage_kernel = false,
$docker_upstream_pkg = false,
$docker_dns = '8.8.8.8',
){
# Set up Docker daemon
class { 'docker':
manage_kernel => $docker_manage_kernel,
use_upstream_package_source => $docker_upstream_pkg,
tcp_bind => "tcp://${docker_bind}:${docker_port}",
dns => "${docker_dns}",
}
firewall { "100 - allow traffic to Docker daemon on ${docker_port}":
port => "${docker_port}",
proto => tcp,
action => accept,
}
}
No Machine?
I think it’s too early to write off Docker Machine as a miss. It is still in a very early development stage, so things might (and probably will) change in the next few weeks or months. Depending on what happens it’s even possible that Docker Machine ends up replacing Boot2Docker in the end.
Time will tell.