Skip to main content
  1. Posts/

Vagrant vs. Docker —— Which One Should You Choose?

·355 words·1 min· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

For an introduction to Vagrant, please refer to the previous article: What is Vagrant? The Difference Between Vagrant and VirtualBox

What is Vagrant
#

For an introduction to Vagrant, please refer to the previous article: What is Vagrant? The Difference Between Vagrant and VirtualBox

Vagrant vs. Docker
#

One of the most frequently asked questions about Vagrant is: What’s the difference between Vagrant and Docker?

Directly comparing Vagrant and Docker without considering the context is inappropriate. In some simple scenarios, their functions overlap, but in many more scenarios, they are not interchangeable.

So, when should you use Vagrant, and when should you use Docker?

Therefore, if you only want to manage virtual machines, you should use Vagrant; if you want to quickly develop and deploy applications, you should use Docker.

Let’s discuss why in more detail.

Vagrant is a VM management tool, or orchestration tool; Docker is a tool used to build, run, and manage containers. The question actually boils down to the difference between a virtual machine (VM) and a container (Container).

Let’s use a set of images from the internet to illustrate the differences between a physical machine (Host), a virtual machine (VM), and a container (Container).

Physical Machine (Host)

物理机

Virtual Machine (VM)

虚拟机

Container (Container)

Docker

From the images, we can more easily understand the differences between a virtual machine (VM) and a container (Container):

FeatureVirtual MachineContainer
Isolation LevelOperating System LevelProcess Level
Isolation StrategyHypervisorCGROUPS
System Resources5 - 15%0 - 5%
Startup TimeMinutesSeconds
Image StorageGBMB

Summary: Differences in Use Cases for Vagrant and Docker

Vagrant is designed to manage virtual machines, while Docker is designed to manage application environments.

Vagrant is more suitable for development and testing, solving environment consistency issues; Docker is more suitable for rapid development and deployment, and CI/CD.

Finally, both Vagrant and Docker have a large number of community-contributed “Boxes” and “Images” available.


Welcome to follow the WeChat official account “DevOps攻城狮” - Focusing on DevOps knowledge sharing.

Related

What is Vagrant? Differences Between Vagrant and VirtualBox
·650 words·4 mins
This article introduces the concept and history of Vagrant, and how to use Vagrant to create and manage virtual machines, emphasizing the advantages of Vagrant over traditional virtual machines.
You Must Know These 17 Docker Best Practices!
·3928 words·19 mins
This article shares some best practices to follow when writing Dockerfiles and using Docker, including suggestions on multi-stage builds, image optimization, and security.
What is Go? Advantages, Current Status, and Choosing Between Python and Go for Beginners
·883 words·5 mins
This article introduces the basic concepts, advantages, and ranking of the Go programming language. It also guides beginners on choosing between learning Python or Go, providing practical learning suggestions and resources.