Skip to content
Tutorials Center
My learning

Topics

Vagrant Tutorial

Learn Vagrant step by step: 36 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Vagrant? Learn what Vagrant is, which problem it solves, how it relates to virtual machines, boxes and providers, and when to choose it over containers.
  2. 2 Installing Vagrant and VirtualBox Install Vagrant and a provider on Windows, macOS and Linux: system requirements, virtualization settings, version checks and fixing the most common setup errors.
  3. 3 Your First Vagrant Machine Create, boot, log into and destroy your first Vagrant virtual machine with vagrant init, up, ssh and destroy, and understand what happens at each step.
  4. 4 CLI Essentials and the Machine Lifecycle Learn the everyday Vagrant commands: up, halt, suspend, resume, reload, status, global-status, snapshots and destroy, and how machine states change.

Vagrantfile and Boxes

  1. 5 Vagrantfile Basics Understand the Vagrantfile: the Ruby DSL, the config object, config.vm settings, variables, loops and conditions, and how to validate your file.
  2. 6 Choosing a Box What a Vagrant box is, how to find trustworthy boxes on Vagrant Cloud, how to pin versions and check updates, and how to pick the right OS image.
  3. 7 Managing Boxes Manage Vagrant boxes from the command line: add, list, outdated, update, prune and remove, plus how versions, providers and disk space work.
  4. 8 VM Settings: Memory, CPUs and Provider Options Configure Vagrant virtual machines: memory, CPUs, names, hostname, GUI, VirtualBox customizations, Hyper-V and libvirt blocks, and sizing advice.
  5. 9 Building Custom Boxes Create your own Vagrant box from a running machine with vagrant package, learn what a base box needs, and see how Packer automates box builds.
  6. 10 Vagrantfile Load Order and Merging Learn how Vagrant finds and merges several Vagrantfiles: box, user-level and project files, override rules, VAGRANT_VAGRANTFILE and config.vm.define.

Provisioning

  1. 11 Provisioning Overview Understand Vagrant provisioners: what they are, when they run, the run options always and never, naming, ordering, idempotence and re-running them.
  2. 12 The Shell Provisioner Use the Vagrant shell provisioner: inline scripts, script files, arguments, environment variables, privileged mode, heredocs, error handling and examples.
  3. 13 File Provisioner and Triggers Copy files and folders into a guest with the file provisioner, understand the destination rules, and run actions before or after Vagrant commands using triggers.
  4. 14 Ansible, Puppet, Chef and Docker Provisioners Provision Vagrant machines with Ansible, ansible_local, Puppet, Chef and the Docker provisioner: configuration, inventories, idempotence and when to use each.

Networking and Synced Folders

  1. 15 Forwarded Ports Reach services in your Vagrant VM from the host with forwarded ports: syntax, host_ip, auto_correct, protocols, privileged ports, collisions and the NAT behind it.
  2. 16 Private and Public Networks Give Vagrant VMs their own IP addresses: private host-only networks with static or DHCP addresses, public bridged networks, adapters, hostnames and troubleshooting.
  3. 17 Synced Folders Share files between host and VM with Vagrant synced folders: the default /vagrant mount, VirtualBox, NFS, rsync and SMB types, options and performance tips.
  4. 18 SSH and Access Connect to Vagrant machines with vagrant ssh, ssh-config, scp and editors; learn the config.ssh options, key handling, agent forwarding and WinRM for Windows.

Multi-machine Environments

  1. 19 Multi-machine Vagrantfiles Define several virtual machines in one Vagrantfile with config.vm.define, target them by name, and control startup order, primary and autostart machines.
  2. 20 Networking Between Machines Let Vagrant machines talk to each other over a private network, use hostnames, forward ports from the right machine, and wait for services before depending on them.
  3. 21 Data-driven Machine Definitions Use plain Ruby in a Vagrantfile to loop over machines, read a YAML file, merge defaults with per-machine overrides, and keep large clusters readable.

Providers and Plugins

  1. 22 Vagrant Providers Overview Understand what a Vagrant provider is, how the box and provider must match, how to choose one, and how to write one Vagrantfile that works with several providers.
  2. 23 Tuning the VirtualBox Provider Configure the Vagrant VirtualBox provider: memory, CPUs, names, GUI mode, linked clones, customize commands, extra disks and sensible defaults for your hardware.
  3. 24 Hyper-V, libvirt and VMware Providers Use Vagrant with Hyper-V on Windows, libvirt and KVM on Linux, and VMware or Parallels on desktops: setup, settings, networking and limits of each provider.
  4. 25 The Docker Provider Use Vagrant's Docker provider to start containers from a Vagrantfile, build images, link containers, and learn when containers beat full virtual machines.
  5. 26 Vagrant Plugins Install and manage Vagrant plugins, use popular ones such as vagrant-hostmanager and vagrant-vbguest, require plugins in a Vagrantfile, and write a tiny plugin.

Team Workflows

  1. 27 Sharing a Vagrantfile in Git Commit a Vagrantfile and its provisioning scripts to Git, ignore the .vagrant folder, handle line endings on Windows, and keep secrets and local overrides out of the repo.
  2. 28 Version Constraints and Pinned Boxes Make environments reproducible by pinning Vagrant, box and plugin versions with Vagrant.require_version, config.vm.box_version and update policies for teams.
  3. 29 Triggers and Automation Use config.trigger to run scripts before or after vagrant up, halt and destroy, back up data, check prerequisites and automate common team tasks with Ruby.
  4. 30 Packaging and Hosting Private Boxes Turn a configured machine into a reusable box with vagrant package, prepare a clean base, host it privately with a metadata JSON file, and version it for your team.

Troubleshooting and Alternatives

  1. 31 Debugging and Common Vagrant Errors Diagnose Vagrant problems with debug logs, the provider GUI and status commands, and fix the usual errors: SSH timeouts, port collisions, box and shared folder failures.
  2. 32 Performance and Windows Issues Speed up Vagrant machines: choose faster synced folder types, give the right resources, avoid slow I/O, and fix Windows problems with symlinks, paths and line endings.
  3. 33 Vagrant vs Docker and Alternatives Compare Vagrant with Docker, Docker Compose, dev containers, Multipass, WSL, Packer and cloud dev environments, and decide when each tool is the right choice.

Projects and Practice

  1. 34 Project: A LAMP Stack Environment Build a complete Linux, Apache, MySQL and PHP development environment with Vagrant: Vagrantfile, provisioning script, synced folder, forwarded port and a test.
  2. 35 Project: A Three-tier Cluster Build a multi-machine Vagrant cluster: HAProxy load balancer, two web servers and a database on a private network, generated from a YAML file with shared provisioning.
  3. 36 Vagrant Practice and Challenges Practice Vagrant with hands-on challenges across multi-machine setups, providers, plugins, team workflows and troubleshooting, with solutions and a self-check script.