Should I Use Vagrant or Docker for Creating an Isolated Environment?

Better Stack Team
Updated on August 1, 2022

This depends on what exactly you want to do. The short answer would be that if you want to manage virtual machines, you want to use Vagrant. If you want to build and run an application environment, you want to use Docker. If you want to know more, let's deep dive a little.

Docker

Docker is a tool for building, managing and running virtual application environments. It creates a standardized environment by packaging the application into lightweight containers that are easily portable. A container can hold pretty much any software component along with its dependencies (executables, libraries, configuration files, etc.), and execute it in a guaranteed and repeatable runtime environment. This makes it very easy to build your app once and deploy it anywhere - on your laptop for testing, then on different servers for live deployment, etc.

It's a common misconception that you can only use Docker on Linux. That's incorrect; you can also install Docker on Mac, and Windows. When installed on Mac, Docker bundles a tiny Linux VM (25 MB on disk!) which acts as a wrapper for your container. Once installed this is completely transparent; you can use the Docker command line in exactly the same way.

Vagrant

Vagrant is a virtual machine manager. It allows you to script the virtual machine configuration as well as the provisioning. However, it is still a virtual machine depending on VirtualBox  (or others) with a huge overhead. It requires you to have a hard drive file that can be huge, it takes a lot of memory, and performance may not be very good.

Vagrant launches machines to run apps/services for the purpose of development. This can be on VirtualBox, VMware. It can be remote like AWS, or OpenStack. Within those, if you use containers, Vagrant doesn't care, and embraces that: it can automatically install, pull down, build, and run Docker containers, for example.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github