Vagrant was a great way to ensure reliable software delivery process. It allowed the developers to use readily available Vagrant boxes and adjust them to create development environments mimicking the conditions in production. But Docker is really becoming mainstream nowadays, so why use Vagrant with Docker being available?
The point is, Vagrant and Docker are not analogs and cannot substitute each other.
Vagrant is a tool from HashiCorp aimed at enabling the developers to create authentic development environments mirroring the conditions in production. It allows creating a VM with exactly the needed combination of OS, software versions, binaries, and libraries. This speeds up the bug fixing process tremendously and ensures the continuity of the process.
Docker, on the other hand, is a product from Docker, Inc. that approaches the task from a diametrically opposite angle. Instead of adapting the dev environment to the demands of the production systems, Docker containers ensure the infrastructure immutability, so the app works exactly the same in development, testing, staging and production — as long as there is the Docker virtualization layer to support the containers.
Therefore, if Docker is so much more useful, why use Docker and Vagrant instead of using Docker alone?
Legacy infrastructure and legacy code are rarely able to support containers without a major investment into redesign and optimization. Sometimes, this investment can require huge expenses that are either not feasible or not in the highest priority right now. Thus said, Vagrant provides a nearly free and very convenient approach to testing your app in various scenarios and fixing the bugs.
However, app containerization and digital transformation of legacy infrastructures are in full swing nowadays. Businesses large and small understand the importance and efficiency of running cloud infrastructures composed of Kubernetes clusters configured by Terraform manifests and holding pods of Docker containers with apps. It provides such a tremendous boost to operational flexibility, ease of monitoring and maintenance, that once the companies taste this approach — they never want to go back to their pre-cloud manual deployments.
Final thoughts on why use Vagrant with Docker
Thus said, there are some cases when using Vagrant with Docker provider is preferable — for example, when splitting a monolithic app into microservices. This is an endeavor that requires a combination of Vagrant and Docker in the development environment to ensure stable operations in production. On the other side, maybe going for the full-Docker environment from the very start can make the transition to microservices easier for all parties involved?