Vagrant vs. Docker: which is better for software development environments?
- CI/CD DevOps Docker Kubernetes News Tools Vagrant
Docker took the software development industry by storm, greatly changing the way we develop the software. However, Vagrant is still a viable option. What are the pros and cons of each tool?
“Works on my computer” is the byword of software development describing the situation when the application behaves unexpectedly, as the real production environment conditions differ from the development and staging ones. Such a situation is actually quite widespread, due to the vast variety of hardware configurations, OS’es, software versions and other variables across the application sphere of usage. This sometimes leads to the uncovering of unexpected bugs by end users and, worst of all, the developers have to pay much effort to reproduce and fix them.
The solution to this issue is known and has been around for awhile: the developers must the software development environments identical to the production ones, so the app code behaves exactly the same way in development, during testing, staging and in production. There are two main DevOps tools that enable such a functionality: Docker and Vagrant. While acting similarly, these tools differ quite a lot. They have different:
- scopes of app isolation,
- security levels,
- speed of launch
- resource consumption
- operational limitations
Below we will compare Vagrant vs. Docker to highlight which of them is better for enabling the software development environments.
Vagrant vs. Docker: scopes of isolation
Vagrant from Hashicorp is a solution that enables quick configuration and provisioning of virtual machines (VMs) that help to isolate the application in its own development environment. These VM’s work on top of real hardware servers but emulate the virtual infrastructure the developer needs — from OS all the way down to libraries and binaries of the required software — and ensure the app works the same no matter the underlying hardware and software, as long as it runs in the VM.
Docker is an open-source platform that allows isolating the apps within code containers similar to Linux Containers (LXC), though Docker moved from LXC to containerd to enable industry-wide standardization. Instead of creating a virtual computer atop a real hardware, a Docker container is a code package with everything needed to run the app code inside. While a single container is created to run a single app, one Vagrant VM can run multiple interacting apps at once. For Docker containers, this is possible using Kubernetes and dockercompose.
Thus said, containers usually weigh several dozens of MBs and multiple containers with separate apps can run atop a single virtual machine.
Vagrant vs. Docker: security levels
As Docker containers use the kernel of the system they run on (be it Linux, Windows or MacOS kernel) there is a possibility that malicious code run within the container will affect other containers on this machine as well as the host operating system. This risk can be mitigated by adding built-in security checks to the container.
With Vagrant the developers must ensure the security of the virtual machine themselves, by installing and configuring any firewalls deemed necessary.
Vagrant vs. Docker: speed of launch
As Docker containers are run in separate code packages, they can be launched in under a minute without affecting the work of other system components. On the other side, a Vagrant VM must be totally rebooted to launch the app anew and all the running apps must be restarted afterward
Vagrant vs. Docker: resource consumption
Vagrant VM’s have to be launched upon the existing host OS’s, so they cost a certain amount of resources to sustain themselves. Docker negates the need for the hypervisor and the whole virtualization level, as containers can be run directly atop 3 most popular OS’s — Linux, Windows, and Mac OS. This allows a tremendous increase in the resource consumption efficiency — a host running containers boasts 300% increased efficiency as compared to running VM’s.
Vagrant vs. Docker: operational limitations
While Docker can be launched on any of the most popular software development OS’s, it does not have native MacOs support as of April 2018 and requires the developers to launch a VM on MacOS. Thus said, Vagrant can run atop any host OS without limitations, yet after exiting the development and testing environments, the app must run atop host machines in staging and production, where multiple inconsistencies might arise.
Final thoughts on Vagrant vs. Docker and which is better for software development
Docker is a production-ready environment that provides consistent app usage experience throughout the whole software delivery pipeline. Built along industry standards, Docker containerization becomes a vital tool for ensuring software delivery continuity, especially when coupled with Kubernetes, Jenkins and other DevOps tools for CI/CD.
On the other hand, Vagrant is specifically designed for software development purposes, so running it in production is not recommended for the sake of all the reasons described above — excessive resource consumption, slow launch/reboot speed, security configuration complexity.
At IT Svit we have ample experience with using both Vagrant and Docker for software development, but we sincerely recommend to stick with Docker for the needs of supporting the app in production. What’s your experience with Docker and Vagrant? Which of them do you find better for software development? Did we miss anything important? Please tell us in the comments below!
Feel free to browse through the latest insights and hints on the DevOps, Big Data, Machine Learning and Blockchain from IT Svit!
Outsourced backend development for a Tokyo-based dating app
Reliable and efficient back-end development is essential for ensuring the whole project success. A Tokyo-based IT Svit customer is very glad he chose IT Svit for delivering these services.
What is DevOps: DevOps services in a nutshell
As different people have a different experience with DevOps services, they have different explanations and definitions of what is DevOps. Below we describe DevOps services in a nutshell.
How to increase the IT infrastructure efficiency in 3 months
One of the most daunting and pressing tasks for any company is the continuous push for improvement of their IT infrastructure. We describe how to increase the IT infrastructure efficiency in 3 months.