Docker vs. Vagrant: Which is Better for Development?

Docker vs. Vagrant? This is a question that many developers and IT professionals have asked themselves when deciding whether to set up a virtual machine or virtual environment.

If you’re just a solo developer, then you usually won’t have to worry about this. You’ll be using the same machine every day. You’ll be using code that works with your specific development environment, and you’ll be pushing it to the same location.

However, if you’re working with other developers on a project, you can run into some serious problems. It’s highly unlikely that each developer on the team is using the same machine. Some will be using Mac, some Windows, and some Linux. This can create a lot of small inconsistencies in the code that’s pushed.

The Need For a Virtual Development Box

Developers needed a way to create a stable virtual box that their whole team could access. This virtual box would maintain consistency. It’s set up to run on a single operating system, with pre-set features and functionality. When developers are finished coding for the day, they can push their code to the virtual box, integrate it with the other code, and ensure that it’s working smoothly.

Docker and Vagrant are two solutions that operate on the principle of virtual development environments. They offer very different solutions that are proven to work very well. In a minute, we’ll go into the specific differences between the two, but first, we need to understand their methods of operation. Docker uses what’s called a virtual environment, and Vagrant is a virtual machine manager.

Virtual Machine

A virtual machine is essentially a cloud server that runs on your machine. It uses the resources provided by your machine to define its limitations (storage, memory, processing power), but it operates as a completely separate virtual machine. Think of it as a computer within your computer. This virtual machine has its own BIOS, network adaptor capabilities, and has allocated processing power and memory. You can install any operating system and software that you like onto your virtual machine and can log into it and use it with a few simple lines from your command line.


All virtual machines run on something called a hypervisor. These hypervisors act as digital supervisors for the virtual machine to ensure that it’s running properly and that no significant problems are being encountered. Some popular hypervisors used today are:

  • VM Ware
  • Microsoft Hyper-V
  • Xen Server
  • KVM

These hypervisors are the software, firmware, and hardware responsible for the creation and maintenance of your virtual box. They are the layer between your native computer and your virtual machines and are vital for their continued functionality. Hypervisors provide data and reporting and inform you whenever an update needs to be made, or resource allocation is getting scarce.

Virtual Environment

A virtual environment is similar to a virtual machine in principle. However, it has one very large key difference. The virtual environment container runs on a single kernel based on the host computers operating system and hardware limitation. This allows you to do away with all of the extra layers required by a virtual machine. You create one environment that operates on your device as an image. You can then create, develop, and deploy your code within this environment.

What is Docker?

Now that you have an idea of how the principles work let’s look at how they are applied in Docker. Docker is an open-source container technology that is based on LXC. It operates on the principles of a virtual environment. Once your download Docker onto your computer you set up a virtual container for each specific development project.

After you set up your first container, you will be able to push your code to a site such as DockerHub, which is essentially GitHub for Docker. The best part about Docker containers is that they only use the computing power that they need. There is no need for a hypervisor to manage them, as you aren’t managing several different separate operating systems.

Also, with Docker, you don’t have to preset the limitations of your container, as you would with Vagrant. In Vagrant, you would have to preset the storage, memory, and all of the other properties before launching your virtual machine. It takes up this amount of resources whether you need it or not. Since Docker runs on the same kernel as the host device, it only uses what it needs and nothing more, so you aren’t wasting overhead on unused resources and hypervisor management.

Docker gives users a far more bare-bones approach to virtual box development environments. However, there can be a lack of security. Because the Docker containers aren’t completely separate as they are in Vagrant, they are more vulnerable to hackers. If a hacker were to get access to your device, then they could easily move into your Docker containers and steal vital information about your code. However, this is a far-fetched scenario and is only an important consideration if your team is working on a state-of-the-art project.

Benefits of Docker

  • Fewer resources allocated
  • Lightweight footprint
  • Faster speeds
  • Runs on your existing kernel
  • No need for a hypervisor

What is Vagrant

Vagrant is a virtual machine manager. It allows you to create multiple virtual machines each with their own allocated resources and operating systems to allow you to develop, test, and deploy your applications on. Vagrant is the software that talks to your hypervisor and manages the creation and access to each of your virtual machines.

The drawback of Vagrant when compared to Docker is that it takes up more resources. As the operating system and hardware requirements of each virtual machine must be present, they will use this up no matter what. However, virtual machines do have the benefit of security.

Because each virtual machine is technically separate from your device and operates on a different kernel, they aren’t prone to indirect hacking attacks. For a hacker to gain access to your Vagrant virtual machines, they would first have to direct a cyber attack on your device, and then they would have to perform a new attack on each individual virtual machine. The average hacker has a very small window of time to operate, and if they have to hack two separate machines, they’re out of luck.

Benefits of Vagrant

  • Allows you to test on different operating systems
  • Separated boxes make environments more isolated
  • Increased security

Docker Vs. Vagrant For Development

Docker uses fewer resources than Vagrant and is more bare-bones which makes it a little bit faster. However, Vagrant excels in security, as each virtual machine is completely separate from the rest. Here’s a quick Vagrant vs. Docker table to put things into perspective.


Software Security Speed Resource Management
Docker + +
Vagrant +


Using Docker With Vagrant

Although many people consider Docker and Vagrant to be competitors, the two services can actually compliment each other. In fact, the Vagrant documentation encourages you to use Docker with Vagrant.

Vagrant Docker Provider

In cases like this, Docker can take over the functionality of a service such as Virtual Box. Developers can create a virtual machine using Vagrant. Later on, they may need to make small changes and use a different configuration with the same properties as the base virtual machine. Docker can be used to create these lightweight, minified versions without the developer needing to create an entirely new virtual machine.

Final Thoughts

Docker and Vagrant are both great services. For most software developers, Docker will be a quicker and more lightweight service. However, if you’re developing high-end programs that need extra security and extensive, in-depth testing environments, then Vagrant’s isolated virtual machines can be incredibly useful.

About the author

Steven Hansen

Steven Hansen is a founder of Techeries. He is a specialist in digital security solution business design and development, virtualization and cloud computing R&D projects, establishment and management of software research direction. He also loves writing about data management and cyber security.