Vagrant 101: An introduction

Not everyone is familiar with Vagrant, therefore here is a 101 introduction into Vagrant.

VagrantVagrant is an open source automation tool, initially developed by Mitchell Hashimoto in early 2010. Since the end of 2012 is Vagrant backed by a company called HashiCorp, which was formed by Mitchell to better support the growing demand.
Vagrant allows the user to create and share development environments, which massively reduces the time and increases quality for deployments.

Vagrant is available for Windows, Mac OS X and Linux and does support automating Linux and Windows based VMs. Since a while does Vagrant also support automating Docker environments. With this great support for heterogeneous host systems a developer can create an environment once and share it with a greater community.

To better understand Vagrant I will explain the most important parts of Vagrant.


Vagrant itself does not include any hypervisor but does have out of the box a provider to automate VirtualBox and Microsoft’s Hyper-V. There is also a provider for Docker container technology. Great about using VirtualBox as your hypervisor is that it also supports multiple operating systems and is Open Source, which makes it to the default provider for Vagrant.
To fund the development of Vagrant does HashiCorp also offer a commercial provider for VMware Workstation and Fusion.
Beside these “official” providers does the open source community extend Vagrant by numerous providers. (AWS, OpenStack, VMware AppCatalyst, …)


Vagrant does not install any operating systems. It uses boxes, you could also say templates, to deploy VMs. There are boxes available which support Virtualbox, VMware, etc. These boxes are most of the time a minimal installation of an operating system with VM tools and necessary modifications. While provisioning a Vagrant environment, the required packages and software will be installed on the fly. Therefore most of the time an online connection is necessary.
Boxes are either distributed via simple download links or via HashiCorp’s Atlas. There is already a huge amount of boxes available which makes it most of the time unnecessary to create your own. You can also create your own boxes with a tool called packer if you can’t find a suitable one publicly. Boxes are cached locally therefore for consecutive deployments you don’t have to download it again.


Knowing about boxes and providers is nice but this only provisions you a minimal operating systems using the provider of your choice. We want more!
Provisioners allows you to customize your box using different approaches like: bash and powershell scripts, puppet, chef and more.
These techniques enable you to create your individual development environment fully automatic, reproducible and distributable.


A Vagrant environment is described by a simple text file called “Vagrantfile” (no file extension). This file is written in Ruby, a programming language, though you don’t need extensive Ruby knowledge to work with Vagrant. Vagrant itself is also written in Ruby. In this file you can specify which box to download, VM modifications, scripts to run and much more.
The following is an example for a simple Vagrantfile that does provision a Ubuntu box using Virtualbox, install Apache and make the webserver available locally on port 8080:

Putting all together

Now that you are aware of the concept and the main components of Vagrant, let’s take the above example and deploy it. You need to have installed Vagrant and Virtualbox.
Create a file called “Vagrantfile” with the above content and save it into and empty directory . Finally issue vagrant up in a shell in this folder to start the deployment.

The output will look similar to this:


After a few minutes, depending of your internet bandwidth, you will be able to test this environment by browsing to .




With ONE command, “vagrant up”, you get a consistent development environment deployed to your host, be it Windows, Linux or Mac without requiring knowledge about Apache, Linux or more.
Using vagrant destroy will clean up the environment.

This is the power of Vagrant and one reason why it is so popular and leveraged for many many projects.

Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “Vagrant 101: An introduction