How are Vagrant and Docker Similiar?

Vagrant is a cross-platform tool that lets you specify Virtual Machines (as a Vagrantfile) to deploy to a hypervisor (like VirtualBox on your laptop or vSphere or Hyper-V at work).

Docker is Linux-only tool that lets you specify Linux Containers (as a Dockerfile) to deploy to any host running Docker.

So they are similar because they both take a config file. But different because Vagrant gives you Virtual Machines in minutes and Docker gives you Linux Containers in milliseconds. In fact, if you want to use Docker on your Mac, you usually use Vagrant to create a Linux VM first and then install Docker on that host (since it depends on the Linux kernel). Creating a Vagrant Linux box is killer easy:

$ mkdir ubuntu
$ cd ubuntu
$ vagrant init ubuntu
$ vagrant up

But the lines between VMs and Containers are blurring. With Vagrant's recent 1.5 release there was a lot added, including Vagrant Cloud. Vagrant Cloud is a hosted service for finding boxes, sharing boxes, managing Vagrant Shares (reverse proxy to any port on your vagrant boxes).

How Does Vagrant Cloud Change Things?

One of the coolest parts of Docker is how collaborative the process of curating encapsulated Linux environments could become. From my laptop, I could now docker commit and docker push. Then from your laptop, someone else can docker pull and docker run your exact same Linux Container. This is revolutionary. This does to Linux what git has done to source control. Vagrant Cloud introduces the same social curation features to any regular Virtual Machine. With vagrant box update, you can pull changes to your virtual machine like docker pull. You can even host private virtual machine images in the Vagrant Cloud. This is very interesting for a number of reasons:

  • Docker will (probably) never run Windows because of it's architecture
  • Vagrant supports a much wider variety of operating systems
  • Vagrant Virtual Machines have better security and isolation than Linux Containers

So, although Virtual Machines are slower than Docker Containers, they make up for it in flexibility and isolation.

Does This Mean The End of Docker?

No. Docker is interesting for many more reasons than just docker commit.

  • Light-weight isolated environments are easier and faster to spin up and down than VMs
  • You can stick multiple containers on a single virtual machine which can save cost
  • Docker Containers are well suited for CI/CD and micro-PaaS solutions

But this is a clear indication that Virtual Machines are not going to give up without a fight.

Conclusion

The worlds of Virtual Machines and Linux Containers are colliding. They are inspiring each other and leading to mutual technical advancements. For example, Serf is a project that comes from the makers of Vagrant but can easily be used with linux containers. The world is headed to a place where Linux Containers co-exist with AND on Virtual Machines. Some startups are already supporting native Linux Container hosting. OpenStack allows Docker Containers as a first-class citizen. We are going to continue to see Vagrant and Docker play really well together and push each other's boundaries, which will only lead to more goodness.