Vagrant questions still come up in DevOps, SRE and build/release interviews because many teams use Vagrant to create repeatable local development and test environments. This guide collects 23 Vagrant interview questions and answers, from the basics to the Vagrantfile, boxes, providers, provisioning, networking, multi-machine setups and troubleshooting, with short code examples you can practise on your own machine.
If you are preparing for a broader DevOps interview, pair this page with our top 30 DevOps interview questions and answers.
Vagrant Basics
1. What is Vagrant?
Vagrant is a HashiCorp tool for building and managing portable development environments. You describe a virtual machine in a text file (the Vagrantfile), and Vagrant creates it on a provider such as VirtualBox, VMware, Hyper-V or Docker, configures networking and shared folders, and runs provisioning scripts. Everyone on the team gets the same environment with a single vagrant up.
2. Why do DevOps teams use Vagrant?
It removes "works on my machine" problems: developers, testers and CI agents can create identical, disposable environments from version-controlled code. Teams also use it to test configuration-management code (Ansible, Chef, Puppet, shell scripts) on clean virtual machines before running it against real servers.
3. What is the basic Vagrant workflow?
A typical workflow is: vagrant init (create a Vagrantfile), vagrant up (create and provision the VM), vagrant ssh (log in), vagrant halt or vagrant suspend (stop or pause it), and vagrant destroy (delete it). Because the environment is defined in code, you can destroy and rebuild it at any time.
4. Which Vagrant commands should you know?
The commands interviewers expect you to know are:
vagrant init ubuntu/jammy64 # create a Vagrantfile for a box vagrant up # create, boot and provision the VM vagrant ssh # open a shell in the VM vagrant status # state of this environment vagrant global-status # all environments on the host vagrant reload --provision # restart and re-run provisioners vagrant provision # re-run provisioners only vagrant halt | suspend | resume vagrant destroy -f # delete the VM vagrant box list | add | update | prune vagrant snapshot save base # save a snapshot named "base" vagrant validate # check the Vagrantfile
5. What is the difference between vagrant halt, suspend and destroy?
halt shuts the VM down gracefully and keeps its disk. suspend saves the running state (memory included) so vagrant resume continues where you left off, at the cost of extra disk space. destroy deletes the VM and its disk; the next vagrant up builds a fresh machine from the box and runs provisioning again.
Vagrantfile, Boxes and Providers
6. What is a Vagrantfile?
The Vagrantfile is a Ruby-based configuration file at the root of the project. It defines the box, provider settings (CPU, memory), networking, synced folders and provisioners. It is committed to version control so the whole team shares one definition of the environment.
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/jammy64"
config.vm.hostname = "app-dev"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vb.cpus = 2
end
config.vm.provision "shell", inline: "apt-get update -y"
end7. What is a Vagrant box?
A box is a packaged base image for a specific provider, for example an Ubuntu image for VirtualBox. Vagrant downloads boxes from a registry (HashiCorp's public box catalogue) or from a URL or file, caches them locally, and clones them to create each VM. Boxes can be versioned, so vagrant box outdated and vagrant box update keep a project on the right version.
8. How do you create your own box?
The usual approach is to build it with HashiCorp Packer, which installs the operating system and tools automatically and outputs a .box file. For a quick one-off you can also run vagrant package on a configured VirtualBox VM. Teams publish internal boxes to a registry or a file share and pin a version in the Vagrantfile.
9. What are providers in Vagrant?
A provider is the platform that actually runs the machine. VirtualBox is the default; Hyper-V and Docker are built in, VMware Desktop/Fusion is supported through the official VMware provider plugin, and community plugins add libvirt, Parallels and others. You choose one with vagrant up --provider=hyperv or the VAGRANT_DEFAULT_PROVIDER environment variable.
10. What are Vagrant plugins? Give examples.
Plugins extend Vagrant with new providers, provisioners or commands. They are installed with vagrant plugin install <name>. Common examples are vagrant-vmware-desktop (VMware provider), vagrant-libvirt (KVM/libvirt provider) and vagrant-vbguest (keeps VirtualBox Guest Additions in sync with the host).
Provisioning and Synced Folders
11. What is provisioning in Vagrant, and which provisioners are available?
Provisioning installs and configures software inside the VM after it boots. Built-in provisioners include shell, file, Ansible (ansible and ansible_local), Chef, Puppet, Salt, Docker and Podman. Using the same Ansible playbooks in Vagrant and in staging is a common way to test infrastructure code locally.
config.vm.provision "ansible" do |ansible| ansible.playbook = "site.yml" end config.vm.provision "shell", path: "scripts/setup.sh", run: "always"
12. When do provisioners run?
By default, provisioners run only on the first vagrant up of a new machine. To run them again use vagrant provision, vagrant up --provision or vagrant reload --provision. Setting run: "always" on a provisioner makes it run on every up or reload, and --provision-with runs only the provisioners you name.
13. What are synced folders?
Synced folders share files between the host and the guest so you can edit code on your laptop and run it inside the VM. By default the project directory is mounted at /vagrant. Types include provider shared folders (for example VirtualBox), NFS, rsync and SMB; NFS or rsync are often chosen for better performance on large projects.
14. How do you change the memory, CPUs or name of a VM?
Use a provider block in the Vagrantfile, for example vb.memory, vb.cpus and vb.name for VirtualBox, then run vagrant reload. Provider-specific settings live inside their own block, so one Vagrantfile can hold settings for several providers.
Networking and Multi-Machine Environments
15. What networking options does Vagrant support?
Three options: forwarded_port maps a guest port to a host port (for example guest 80 to host 8080); private_network gives the VM an address on a host-only network, either a static IP or DHCP; public_network bridges the VM onto your physical network so other machines can reach it.
16. How do you handle a port collision?
If another process or VM already uses the host port, add auto_correct: true to the forwarded_port line so Vagrant picks a free port and reports it during vagrant up, or choose a different host port explicitly.
17. What is a multi-machine Vagrant environment?
One Vagrantfile can define several VMs, for example a web server, a database and a load balancer, each with its own box, IP and provisioners. You manage them together or individually with commands such as vagrant up db and vagrant ssh web. This is useful for testing clusters and service-to-service networking locally.
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/jammy64"
config.vm.define "web" do |web|
web.vm.network "private_network", ip: "192.168.56.10"
end
config.vm.define "db" do |db|
db.vm.network "private_network", ip: "192.168.56.11"
end
end18. What are Vagrant triggers and snapshots used for?
Triggers run commands before or after Vagrant actions, for example backing up a database before vagrant destroy. Snapshots (vagrant snapshot save, restore, push, pop) capture the VM state so you can roll back quickly after a risky change.
Troubleshooting and Scenario-Based Vagrant Questions
19. vagrant up hangs at "Waiting for machine to boot". What do you check?
Check that hardware virtualization (VT-x/AMD-V) is enabled in the BIOS, that another hypervisor such as Hyper-V is not blocking VirtualBox on Windows, and open the provider GUI to see the boot screen. Run vagrant up --debug (or set VAGRANT_LOG=info) for detailed logs, and confirm the box version matches the provider version.
20. Synced folders fail after a VirtualBox upgrade. Why?
A common cause is a mismatch between the VirtualBox Guest Additions inside the box and the VirtualBox version on the host. Update the box, install matching Guest Additions (the vagrant-vbguest plugin can automate this) or switch the synced-folder type to rsync or NFS.
21. Your provisioning script works the first time but fails on re-runs. How do you fix it?
The script is not idempotent. Make every step safe to repeat: check whether a package or file already exists before creating it, use package managers that skip installed packages, or move the logic to Ansible, whose modules are designed to be idempotent. Test with vagrant provision several times in a row.
22. How would you use Vagrant in a CI pipeline?
Use it to test infrastructure code on clean machines: the pipeline runs vagrant up, applies the playbook or scripts, runs tests (for example with Testinfra or InSpec) and finishes with vagrant destroy -f. The CI agent must support nested virtualization or a provider such as Docker; many teams now use containers for application builds and keep Vagrant for OS-level testing.
Vagrant vs Docker vs Terraform
23. How is Vagrant different from Docker and Terraform?
Vagrant manages full virtual machines, each with its own operating system and kernel, mainly for local development and testing. Docker runs containers that share the host kernel, so they start faster and use fewer resources, and they are used from development through production. Terraform provisions real infrastructure such as cloud networks, VMs and databases through provider APIs. All three are HashiCorp-style "infrastructure as code", but they solve different problems and are often used together.
| Tool | Runs | Main use |
|---|---|---|
| Vagrant | Virtual machines (full OS) | Repeatable local dev and test environments |
| Docker | Containers (shared kernel) | Packaging and running applications |
| Terraform | Cloud and on-premise resources | Provisioning production infrastructure |
Prepare for Your DevOps Interview with Hachion
Vagrant questions are usually part of a wider DevOps interview that also covers CI/CD, containers, Kubernetes and infrastructure as code. Practise with our DevOps interview questions and answers and Docker and Kubernetes interview questions, or learn these tools hands-on in Hachion's DevOps training online.
Frequently Asked Questions
Is Vagrant still used in 2026?
Yes. Containers have replaced Vagrant for many application workflows, but teams still use it for full-OS test environments, testing configuration-management code and training labs, so it continues to appear in DevOps interviews.
Is Vagrant free?
Vagrant is free to download and use. HashiCorp moved it from the MPL open-source licence to the Business Source License (BSL 1.1) in 2023; check the licence terms if you plan to embed it in a commercial product.
Do I need VirtualBox to use Vagrant?
No. VirtualBox is the default provider, but Vagrant also works with Hyper-V, Docker, VMware (through the official plugin) and community providers such as libvirt.

