Vagrant
Download and Run the installer for Windows system.
The installer will automatically add
vagrant
to your system path so that it is available in terminals.Verify the correct installation using the
vagrant
command inside PowerShell.The primary function of the Vagrantfile is to describe the type of machine required for a project, and how to configure and provision these machines. Vagrantfiles are called Vagrantfiles because the actual literal filename for the file is
Vagrantfile
.Vagrant is meant to run with one Vagrantfile per project.
When you run any
vagrant
command, Vagrant climbs up the directory tree looking for the first Vagrantfile it can find, starting first in the current directory.
This feature lets you run
vagrant
from any directory in your project.Find more boxes at HashiCorp's Vagrant Cloud box catalog
Default Provider
If you have the VMware provider installed, it will always take priority over VirtualBox.
Check more infos about Default Providers here
E.g.
VirtualBox
Install VirtualBox & VirtualBox Extension Pack (default Vagrant provider)
Create a new directory for the vargrant project
Open
PowerShell
and move into the project directoryInitialize the directory with a box, in this case the
hashicorp/bionic64
box will be used
box add
subcommand can be used to install a box without creating a new Vagrantfiledo not add it if already initialized
This will download the box named
hashicorp/bionic64
from HashiCorp's Vagrant Cloud box catalog, where you can find and host boxes.Boxes are globally stored for the current user. Each project uses a box as an initial image to clone from, and never modifies the actual base image. This means that if you have two projects both using the
hashicorp/bionic64
box you just added, adding files in one guest machine will have no effect on the other machine.
Use the box as a base in the project by opening the
Vagrantfile
. Content must be:
The
hashicorp/bionic64
in this case must match the name you used to add the box above. This is how Vagrant knows what box to use. If the box was not added before, Vagrant will automatically download and add the box when it is run.
Bring up the virtual machine
VirtualBox - created and started VM
SSH into the machine:
Destroy the machine
Remove the box
Extras:
Suspend the VM
The virtual machine will still use disk space while suspended, and requires additional disk space to store the state of the virtual machine RAM.
Gracefully shutdown the VM
Halting your machine will cleanly shut it down, preserving the contents of disk and allowing you to cleanly start it again.
VMware Workstation
Install VMware
To upgrade the Vagrant VMware utility, download the latest version from the Vagrant VMware utility downloads page and install the system package to your local system.
You can install or update the Vagrant VMware plugin to the latest version by re-running the install command:
Create a new directory for the vargrant project
Open
PowerShell
and move into the project directoryInitialize the directory with a box, in this case the
hashicorp/bionic64
box will be used
Set the GUI in the
Vagrantfile
to show the VMs in the VMware dashboard (provider settings here)
Bring up the virtual machine and try to SSH into it
VMware Workstation - created and started VM
Shutdown the VM and destroy it
đ
After stopping the VM with
vagrant halt
, at the second boot withvagrant up
this error could appear â:Vagrant encountered an error while attempting to prune unused port forward entries
To solve this port forwarding issue use this command:
Then bring up again the VM with
vagrant up --provider=vmware_desktop
command.
Last updated