When to use Vagrant vs Docker

posted in: Blog | 0

Vagrant and Docker are the tools that are widely used in the software delivery lifecycle. While they serve similar goals, their features and the way they operate distinguish them from one another greatly. Today we discuss when to use Vagrant vs Docker.

Vagrant is an open-source VM management tool built on Ruby, originally developed by HashiCorp. It is a great solution for building and managing unique development environments, fully replicating the conditions of production servers.

Why is it so important? Because “works fine on my machine” was the byword of software development, as the developers could not possibly test the code on all the variety of OS’s, software versions and libraries the product will be run on in production. This is great, yet has certain limitations — every VM must be created and configured every time, as it has to be deleted to free up the resources.

Docker is an open-source container management tool built on Go, originally developed by Docker, Inc. It offers an innovative approach to app development and delivery, as containerized apps can be quickly launched and easily managed in any environment where Docker is installed.

Why is it so important? Docker revolutionized the way we develop and manage software. With it, launching a new instance of an app is as simple as composing an appropriate container from a configurable Docker image with a single command. This is incredible, as it makes both software development and IT infrastructure management much easier and more predictable. The downside is the impossibility to delete unused Docker Images, so the Docker Registry size can grow quite fast, but the community is trying to solve this problem at the moment.

Let’s take a look at when to use Vagrant vs Docker https://itsvit.com/blog/vagrant-vs-docker-better-software-development-environments/.

Vagrant use cases

As we explained before, none amount of development and testing can cover all the variety of software configurations the app will run against in production. This has often lead to bugs being discovered by end users and the developers had to dedicate much effort to simply reproduce the bug in order to be able to fix it.

Vagrant addressed this problem by allowing the IT engineers to create virtual machines (VMs) that exactly mimic the software configuration in production. The virtual machine could receive any needed OS, the exactly neede versions of any software and all the other variables to reliably reproduce the bug. This became the main Vagrant use case.

The other scenario where Vagrant shines is when you have to work with the system that is not supported by Docker, (MacOS or BSD, for example). This enables the developers to have a consistent workflow and work without waiting for Ops engineers to configure the environments. What is even better, there are lots of pre-configured Vagrant environments (so-called Vagrant boxes), allowing any developer to download and adjust them to their needs.

Docker use cases

Docker containers are envelopes of code that contain everything required to run an app — an OS, all the libraries and drivers, software and dependencies. Their main benefit is that they are like building blocks for cloud infrastructure — the images can be easily adjusted, the resulting containers are immutable.

Thus said, Docker containers run the same on any underlying infrastructure, ensuring the same workflow will happen in any production environment. This ensures both the safety of mind, the ease of management and the reproducibility of any situation.

However, the main benefit of Docker over Vagrant is its resource usage cost-efficiency. Containers don’t need a hypervisor and can be launched and rebooted in great numbers instantly. As independent research showed, an infrastructure built on Docker was 300% more efficient, as compared to running the same number of instances on Vagrant VMs.

Conclusions on when to use Docker over Vagrant

As you can see, in the majority of cases it is best to use Docker over Vagrant. However, if you are in doubt when to use Vagrant or Docker during software development — use Vagrant! It was built for the purpose of providing hassle-free and predictable software delivery pipeline — and it works best for this case. Docker, on the other hand, is the best choice for running apps in production and works wonders atop Kubernetes and Terraform cluster.