← Back to tools

Vagrant

Build and manage reproducible virtual machine environments

Description

Vagrant is a tool for building and managing virtual machine environments in a single workflow. It provides easy-to-configure, reproducible, and portable work environments using providers like VirtualBox, VMware, and Docker. Vagrant lowers development environment setup time and increases production parity.

When to use this tool

Good fit when
  • Setting up reproducible development environments across a team
  • Need isolated virtual machines for testing or development
  • Building multi-machine environments that mirror production
  • Want declarative VM configuration checked into version control
Avoid when
  • Working with containers (use Docker or Podman instead)
  • Need lightweight ephemeral environments without full VMs
  • Running on machines without virtualization support

Install

homebrewbrew install vagrant

AI Summary

Tool for building, configuring, and managing reproducible virtual machine environments using a simple declarative Vagrantfile with support for VirtualBox, VMware, Docker, and other providers.

Capabilities

  • + Create and configure virtual machines from a Vagrantfile
  • + Provision VMs with shell scripts, Ansible, Chef, or Puppet
  • + Share and distribute pre-built VM images (boxes)
  • + Sync folders between host and guest machines
  • + Configure networking, forwarded ports, and multi-machine setups
  • + Support multiple providers including VirtualBox, VMware, and Docker

Use When

  • Setting up reproducible development environments across a team
  • Need isolated virtual machines for testing or development
  • Building multi-machine environments that mirror production
  • Want declarative VM configuration checked into version control

Avoid When

  • x Working with containers (use Docker or Podman instead)
  • x Need lightweight ephemeral environments without full VMs
  • x Running on machines without virtualization support

Usage Patterns

Initialize and start a VM

vagrant init ubuntu/jammy64 && vagrant up

Creates a Vagrantfile with Ubuntu 22.04 and boots the VM

SSH into a running VM

vagrant ssh

Opens an SSH session to the default machine

Destroy and recreate from scratch

vagrant destroy -f && vagrant up

Tears down the VM and provisions a fresh one

Take and restore a snapshot

vagrant snapshot save clean-state

Saves the current VM state for later restoration

Input / Output

stdin: Accepts confirmation input for destructive operations
stdout: VM status, provisioning output, and SSH session
stderr: Error messages and provider warnings

Typical Pipelines

vagrant up && vagrant ssh -c 'run-tests.sh' to boot a VM and run tests
vagrant status | grep running to check which machines are active
vagrant snapshot save before-update && vagrant provision to safely re-provision

Related Tools

View AGENTS.md for Vagrant