Vagrant — Portable Development Environments Made Simple
Vagrant is a tool for building and managing portable development environments. Define your environment in a Vagrantfile, run vagrant up, and get a fully configured virtual machine — ensuring every developer works in an identical environment.
What it is
Vagrant is an open-source tool by HashiCorp for building and managing portable development environments. You describe your environment in a declarative Vagrantfile, run vagrant up, and get a fully configured virtual machine regardless of your host OS.
Vagrant is best suited for teams that need OS-level isolation beyond what containers provide. If you need to test on different kernels, run full system stacks, or develop software requiring kernel-level access, Vagrant remains the right choice.
How it saves time or tokens
Vagrant eliminates manual environment setup. Instead of writing a wiki page with 30 steps that each developer interprets differently, you commit a single Vagrantfile. New team members run vagrant up and get an identical environment in minutes. Provisioners (shell scripts, Ansible, Chef, Puppet) automate every configuration step, removing human error from the loop.
How to use
- Install Vagrant and a provider (VirtualBox is the default free option)
- Initialize a project with a base box:
mkdir my-project && cd my-project
vagrant init ubuntu/jammy64
- Start and connect to the VM:
vagrant up
vagrant ssh
- Customize the Vagrantfile for your stack (forward ports, sync folders, run provisioners)
Example
# Vagrantfile
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/jammy64'
config.vm.network 'forwarded_port', guest: 3000, host: 3000
config.vm.synced_folder '.', '/vagrant'
config.vm.provision 'shell', inline: <<-SHELL
apt-get update
apt-get install -y nodejs npm
cd /vagrant && npm install
SHELL
end
Run vagrant up and your Node.js environment is ready with port 3000 forwarded to your host.
Related on TokRepo
- DevOps automation tools — broader category of infrastructure automation resources
- Self-hosted tools — other tools you can run on your own infrastructure
Common pitfalls
- Using VirtualBox on Apple Silicon Macs without switching to a compatible provider like VMware or Parallels
- Forgetting to add the Vagrantfile to version control, defeating the purpose of reproducible environments
- Over-provisioning VMs with too much RAM or CPU when the workload does not require it
Frequently Asked Questions
Vagrant manages full virtual machines with their own kernel, while Docker runs containers sharing the host kernel. Use Vagrant when you need OS-level isolation, kernel testing, or Windows/Linux cross-platform development. Use Docker when you need lightweight process isolation for microservices.
Vagrant supports VirtualBox (free, default), VMware (paid plugin), Hyper-V (Windows), Parallels (macOS), and cloud providers like AWS and Google Cloud. You choose a provider based on your host OS and performance requirements.
Yes. Vagrant can provision a VM that runs Docker inside it, or you can use the Docker provider to let Vagrant manage containers directly. This is useful for teams that want Vagrant's workflow but Docker's runtime.
Vagrant remains relevant for full-OS testing, multi-OS development, and scenarios where kernel-level access matters. It is not a competitor to Docker but serves a different use case: full machine virtualization with reproducible configuration.
Commit the Vagrantfile to your repository. Each developer runs vagrant up to build the same environment. For custom base boxes, host them on Vagrant Cloud or an internal HTTP server and reference them in the Vagrantfile.
Citations (3)
- Vagrant Documentation— Vagrant supports VirtualBox, VMware, Hyper-V, and cloud providers
- Vagrant GitHub Repository— Provisioners include shell, Ansible, Chef, Puppet
- HashiCorp Vagrant— Vagrant is maintained by HashiCorp
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.