01 Overview
Vagrant scripts the creation of local virtual machines against a chosen provider (VirtualBox, libvirt, Docker) so a whole team can boot the same disposable dev environment with one command.
→ official documentation02 Installation
Pick a platform. Each step is copy-pasteable on its own.
01 Install prerequisites
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
02 Add the HashiCorp GPG key and repo
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
03 Install Vagrant
sudo apt-get update && sudo apt-get install -y vagrant
04 Verify
vagrant --version
01 Add the HashiCorp repo
sudo dnf install -y dnf-plugins-core sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
02 Install Vagrant
sudo dnf install -y vagrant
03 Verify
vagrant --version
01 Install via Homebrew
brew install --cask vagrant
02 Verify
vagrant --version
Note — commands assume sudo privileges and an up-to-date package index. Pin a specific version in production rather than tracking latest.
03 Install script
The steps above bundled into a single idempotent shell script for provisioning boxes unattended.
install-vagrant.sh
Ubuntu/Debian target · safe to re-run · exits non-zero on failure
04 Cheatsheet
The commands reached for most often once Vagrant is installed.
| Command | What it does |
|---|---|
| vagrant init hashicorp/bionic64 | Create a Vagrantfile for a base box |
| vagrant up | Create and boot the VM |
| vagrant ssh | SSH into the running VM |
| vagrant halt | Stop the VM |
| vagrant destroy | Delete the VM entirely |
| vagrant status | Show current VM state |
| vagrant provision | Re-run provisioning scripts on a running VM |