Vagrant is a tool that permit to quickly set up a clean “throwable” headless virtual development environment. One of the main goals of this software is to allow a team to work under an exact same controlled environment (usually a linux). No matter what the host OS is (Windows, Mac OS, Linux), it can be destroyed and rebuilt easily on demand with some simple commands. The must would be to make it as closed as possible to the production environment thanks to the easy but powerful YAML configuration file, and his support of multiple script languages or configuration management tools in order to provision the VMs like shell, Chef, Puppet, Ansible, CFEngine…
To create a vagrant environment, the steps are quite simple. Even better if you are part of a team that already uses vagrant, only steps 1, 4, 5, 6 and 7 are required.
- First be sure to have Virtualbox installed in your computer and install Vagrant.
- Choose a seed box from Atlas (ex-vagrant-cloud) that suits your needs best.
- Put the Vagrant configuration file to the root of your project, be sure it is correct and add it to your source control.
- If needed, create a provision file with your favorite scripting language supported by vagrant in order to install what is required, to get your environment fully operational. And don’t forget to specify it into the Vagrant configuration file.
- Run “vagrant up” where your Vagrant file is, with “–provision” if you have a provision file.
- If target OS is a Linux/Unix, run “vagrant ssh” in order to connect to it with SSH protocol.
Docker is not a tool that creates virtual machines! Docker creates containers that can directly use the host machine resources and its kernel. Thought, Docker is based on Linux containers (LXC) so it only works in a Linux environment (for now).
However, before you close the tab and go back to work because you don’t use Linux, it doesn’t mean you can’t use Docker on another OS.
Docker provides a software (Boot2Docker) that can be installed on Windows and Mac. It will create a very tiny (»25mb) Linux virtual machine on your system and run Docker in it. Therefore you can install Docker on every OSes. It won’t be native like on a Linux system but with the powerfulness of current virtualization technologies it won’t really matter, even more since most of the time people will still run Docker in virtualized environment.
“Okay, Docker is not a VM, I get it, but what is it and why should I use it? It’s just gonna give me more work to put something in production and I don’t really see what is the utility in it. It sounds like today’s trendy topic, the FOTM (Flavor of the month) and people are just excited about it because it’s a new technology!”
This is what you might think. At least, it’s what can be heard many times, and one has to give credits to the people who think that. I first was excited by Docker because of the hype around it and also because it looks like a new exciting technology. The little geeky imp inside me wanted to try it but without understanding the purpose of Docker in a real situation.
But after assisting to the presentation done by our two super DevOps addicts, if there was a dialogue that everybody in IT have already encountered to sum up what Docker can solve, it would be:
– “Guys! The app crashed in prod!”
– “But it works on my machine!”
To better understand what Docker is, the best explanation comes from Docker itself:
Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. Consisting of Docker Engine, a portable, lightweight runtime and packaging tool, and Docker Hub, a cloud service for sharing applications and automating workflows, Docker enables apps to be quickly assembled from components and eliminates the friction between development, QA, and production environments. As a result, IT can ship faster and run the same app, unchanged, on laptops, data center VMs, and any cloud. (docker.com)
If you prefer an explanation from the creator of Docker itself (Solomon Hykes), I highly encourage you to watch this great introduction video:
The idea behind Docker is:
Make your application running and working on the needed environment no matter the hosting environment and stop hacking your production environment to make it work!
“Okay why not, I could try it but how it really works? And how is it different from what I already do with a virtualized production environment where each application has its own environment?”
Well the image given during the show (yes it was a show, really! 😉 ) is better than every word I could use to describe it.
On the left you have a production server using virtualization for each application, it’s heavy, slow to set up and start, and takes a lot of resources from the host machine.
On the right, on the other hand, you can see that only one host OS is needed (virtualized or not) and each application are launch in their very own container using the host OS resources and sharing the kernel. Another great thing, where you could argue that VMs could do the same but I would be harder taking more time and being heavier, is if you need to change your host OS or you need to change your physical server, is the ability to easily switch from one host to another with no worry because you know “it will just work”.
I hope you now better understand the concepts of Vagrant and Docker. If you are interested in learning more about them, here some useful links about both of them to get you started! Vagrant and Docker.
Want to know more about DevOps? Ask for our free presentation