Install Vagrant
Vagrant is a tool for building and managing virtual machine environments in a single workflow which lowers development environment setup time and increases production parity.
Notice
The Package Manager method's explanation is based on Ubuntu distribution of GNU/Linux. For more distributions explanations, please visit Vagrant's Official Website.
Installation Guide
You can either download the latest version from Vagrant website and install it, or use your package manager instead. Here's an explanation of both methods: * #### Using Zip File * #### Using Package Manager
Using Zip File
First, download the Vagrant's latest zip file on your host using:
After the file has been downloaded, you need to unzip the file using the command below: In order to use the command globally, copy the extracted contents to binary directory: You can confirm the installation by checking the version:Using Package Manager
In this method, as the Vagrant's Official download page mentions, you need to run these commands in order:
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vagrant
Start With Vagrant
Making A Directory
It's better to create a directory to store your VM's Vagrantfile:
Initialize Vagrant
To initialize your first VM, use:
This command, will create a Vagrantfile which configures your VM. You can change it with your own customizations.Boxs
Vagrant boxes help you create your VM based on different platforms. They include a readily-available Vagrantfile which can be altered. Boxes can be downloaded from the Official Vagrant's Boxes page. Use this command to initialize your VM with Ubuntu 20.04:
Another option would be configuring Vagranfile: Use this command to see all your Vagrant boxes:Basic Commands
-
To run your VM:
-
To shut down your VM:
-
To suspend your VM:
-
To validate the Vagrantfile:
-
To provision your VM:
-
To run your VM without provisioning:
-
To SSH into your VM:
If you are using VirtualBox's GUI, the default user and password of your VM would be 'vagrant' and 'vagrant'. -
To destroy your VM and associated files and drives:
-
To destroy it with force:
-
To check your VM status
-
To check all your VMs' status
-
To reload your VM: