Docker vs Vagrant

There are number of development tools are available today, I will me doing quick comparison of Docker & Vagrant.

If you don’t know about Docker or Vagrant, no worries. Let’s start to understand one by one.

What is Vagrant?

Vagrant provides configureable, portable and reproducible development environment. It is a tool that provides consistent development workflow across multiple OS.

Vagrant is a virtual machine based environment that requires either VirtualBox or Parallel

What is Docker?

Docker supports building, shipping and running distributed applications. It is a container based & containers are generally more lightweight than virtual machines and more faster to Start/Stop them.

It’s sound like both are configureable and development platform, then what is the main difference?

Let’s dig deeper.

Difference between Docker & Vagrant:

While acting so similar, these tools differ quite a lot.

  • Security Levels
  • Isolation scopes for apps
  • Launch speed
  • Resource consumption
  • Limitations

Security levels

Docker containers use the kernel of the system they run on, for example (Linux, Windows or Mac).

And there is possible risk that malicious code run in one container will effect other containers running on the machine as well as the hosting OS.

But this risk can be mitigated by adding build-in security check to the container.

Docker Infrastructure

Vagrant where as rans virtual machine and potential security risk effects the VM itself and that can be avoided by installing the any firewall deemed necessary.

Isolation scopes for apps

Vagrant provides quick configuration & provisioning of virtual machines that isolates the application in it’s own development environment.

VM works on top of the real hardware and emulate the virtual infrastructure required for the application.

Vagrant ensures that application works similar way no matter the underlying hardware or software are as long as it runs in VM.

Vagrant Infrastructure

Docker allows to isolate the applications within the code containers, instead of creating virtual computer on top of real machine, docker container is packaged with everything required by the application from operating system to libs.

Launch Speed

Vagrant can host multiple application in single VM, and therefore if you are running multiple apps in same VM launching VM would be far slower than Docker container. Vagrant need to be fully rebooted to launch the apps and restarted services.

Docker on the other had runs containers, and when starting/stopping or restarting a single container will not effect on other containers, and launch will but much faster than Vagrant VM.

Resource Consumption

Vagrant runs VM on top of OS and allocate resources to work, so that they cost certain amount of resources.

Docker on the other hand runs containers and doesn’t allocated resources and runs directly top of OS, that is much more faster than Vagrant.

Final thoughts

Docker is production ready environment that provides perfect app usage experience throughout the process from development to deployment.

Vagrant is specifically designed for software development purposes.

Author: Danyal
I'm working as programmer since 2002. Born, grew up, studied and worked in Pakistan now Im located in Denmark since 2006.