How to Create a Local Development Environment using Vagrant and VirtualBox

Vagrant allows you to start up a pre-built virtual machine with just two commands from a terminal. Vargrant uses Oracle's VirtualBox to run several virtual machine guests on Windows, MacOS or Linux hosts.

To initialise a new box to download to your local machine, do:

$ vagrant init ubuntu/focal64

This will create a Vagrantfile in your current directory that looks something like:

To start the Virtual Machine, use the

$ vagrant up

command in the same directory as the Vagrantfile

You should now see your VM running in the Oracle VirtualBox Manager GUI:

Now that the ubuntu-focal VM is up and running, we can SSH into it by opening a new terminal in the same directory as the Vagrantfile, and running

$ vagrant ssh

Related Links: