Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Vagrant and Docker: a Comparison

DZone's Guide to

Vagrant and Docker: a Comparison

Vagrant and Docker are both virtualization solutions. Let's compare the features, pros and cons of each to see which is better and if they can work together.

· DevOps Zone
Free Resource

The Nexus Suite is uniquely architected for a DevOps native world and creates value early in the development pipeline, provides precise contextual controls at every phase, and accelerates DevOps innovation with automation you can trust. Read how in this ebook.

The virtualization process that is provided by Vagrant and Docker can be a solution for the modern distributed applications development problems. In this article, I will briefly introduce and summarize the software products Vagrant and Docker, and compare the major features of these technologies, their pros, cons, and main challenges. 

Vagrant and Docker

Vagrant

Vagrant is an open-source software product and tool for building and configuring virtual environments for development. It is designed to run on top of almost any Virtual Machine (VM) tool – VirtualBox, VMWare, AWS, etc. The fact that Vagrant is a VM enables you to integrate Vagrant with CM tools such as Chef, Salt, and Puppet. Vagrant + VirtualBox is the most common combination I heard about.

Docker

Docker is a software for automating the deployment and management of applications in a virtualization environment at the operating system level. It allows you to “package” an application with all its environment and dependencies into a container that can be transferred to any Linux system with support for control groups in the kernel, and also provides a container management environment.

You can read more information about Docker, its latest version, and benefits for users.

Docker and Vagrant simply mean virtualization in varying degrees, Docker as a means of virtualization at the kernel level, and Vagrant being more like full virtualization.

Vagrant and Docker

Let’s start with similarities. Vagrant + VirtualBox and Docker actually provide the same functionality:

  • A virtual machine with one root process – Docker.   
  • Distributed images of these virtual machines.
  • An ability to transfer ports of the virtual machine to the host.
  • An ability to mount host directories inside the virtualized environment or machine.
  • An ability to organize an internal network of virtual machines or environments.
  • An ability to start/stop the composition of virtual machines or environments.
  • An ability to save, upload, and download a snapshot of a virtual machine or environment. 

Virtualization Type

Vagrant and Docker have two different types of virtualisation. Vagrant is related to virtual machines and Docker is a virtual environment tool.

Support

Today, Docker already can be used not only on Linux, but also on Windows Office and macOS, and Vagrant is available for the same operating systems.

Usability

Compared to Docker, Vagrant is easier to understand and to get up and running. Docker’s architecture is harder to understand. 

Size & Speed

Vagrant has a sophisticated working issue; it only works with full virtualization, regardless of what we use- for example, Virtual Box or Hyper-V. Vagrant is also full-virtualization in the case of including virtualization of hardware. Therefore, it is heavy to run and large in size. Also, it is considered difficult to use for integration when launched in production.

Docker is paravirtualization-based. In fact, Docker performs the same tasks and roles as Vagrant, only once in Linux, while having the advantage in speed and size. However, if the program you use is quite large and you need to create several containers for different versions of the program, then the disk space immediately eats up to 5-6 GB. Docker has an almost instant startup due to the fact that you don’t need to initialize the system and the container only needs to run the binary specified for it by the entry point.

However, talking about Vagrant, there is a minimum of 5-7 GB spent on only one container. That’s why it seems that Docker is more convenient in size and faster. 

Conclusion

Although it is not that common, Vagrant and Docker can work together; for example, in some cases, Docker uses Vagrant, or Docker is even used as a provider within Vagrant.

The comparison of Vagrant and Docker has a place and many developers discuss it actively; of course, there is no “right” or “wrong” opinion. I think it really depends on how you want to use it and what you personally feel comfortable working with.

By the way, I would be curious to know your preferences in the comments below. Do you prefer Docker, Vagrant, or maybe something else?

The DevOps Zone is brought to you in partnership with Sonatype Nexus.  See how the Nexus platform infuses precise open source component intelligence into the DevOps pipeline early, everywhere, and at scale. Read how in this ebook

Topics:
docker ,vagrant ,containers ,devops ,virtualization

Published at DZone with permission of Margarita Shilova. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}