What is Vagrant?
In this tutorial, you will create your first development environment with Vagrant. This quick start provides a brief introduction to Vagrant, its prerequisites, and an overview of three of the most important Vagrant commands to understand.
Vagrant isolates dependencies and their configuration within a single disposable, consistent environment, without sacrificing any of your existing tools. To learn more about the benefits of Vagrant, read the "Why Vagrant?" introduction page.
The getting started tutorials use Vagrant with VirtualBox, since it is free and available on every major platform. Vagrant can work with many other providers.
Prerequisites
- Install the latest version of Vagrant.
- Install a virtualization product such as; VirtualBox, VMware Fusion, or Hyper-V.
VMware Fusion: There is an additional plugin and configuration required, review the documentation for guidance. Also, note that it is in tech preview for Apple Silicon.
Your first virtual machine
With the two commands below, you will have a fully usable virtual machine with Ubuntu 18.04 LTS 64-bit.
Initialize Vagrant
Before you can continue to the next step, ensure that Vagrant has created a Vagrantfile
.
Start the virtual machine
Now that you have a Vagrantfile
that configures your deployment, you can start the virtual machine.
When the virtual machine is successfully deployed, there will be a message stating that it is booted and ready.
Connect to the machine with vagrant ssh
and explore your environment.
Leave the SSH session with logout
.
Destroy the virtual machine
When you are done, be sure to terminate the virtual machine. Confirm when the CLI prompts you by typing y
.
Next steps
Vagrant allows you to work on any project, to install every dependency that project needs, and to set up any networking or synced folders, so you can continue working from the comfort of your own machine.
You have just created your first virtual environment with Vagrant. Read on to learn more about project setup.