Running a VM with Vagrant

In this section you will find instructions on how to setup an Ubuntu 16.04 VM using Vagrant

Vagrant Setup

Download Vagrant from the official web site. Choose the installer matching your operating system and architecture.

Installation process is straightforward, refer to Vagrant official documentation if you encounter any problems.

At the end of the installation process log out your system and log back in.

Vagrant is going to need a provider in order to setup the Virtual Machines. VirtualBox is supported out of the box. Just make sure you install one of the supported versions of VirtualBox

Open a terminal and type vagrant version. A message containing the installed version of Vagrant will be printed on the terminal

Installed Version: 2.0.2
Latest Version: 2.0.3

Virtual Machine Setup

Now that Vagrant is installed let’s create our Ubuntu Virtual Machine. Open the terminal and create a new folder called vagrand. Within folder vagrand create a new file called Vagrantfile with following content.

Vagrant.configure(2) do |config| = "ubuntu/xenial64"

  # To automatically configure a private network uncomment following line.
  # "private_network", ip: ""

  config.vm.provider "virtualbox" do |vb|
  # Customize the amount of memory on the VM:
     vb.memory = "4024"

  # Port forwarding: If unneeded comment or remove following lines "forwarded_port", guest: 80, host: 8001 "forwarded_port", guest: 8000, host: 8000 "forwarded_port", guest: 8080, host: 8080


This Vagrantfile containing the settings for the virtual machine, notably the variable set to “ubuntu/xenial64” will tell Vagrant the specific VM we want to run (Ubuntu 16.04 “Xenial Xerus”, 64 bit version). Please take note of comments regarding private network setup, amount of memory and port forwarding within this file. Further visit official vagrant documentation for more explanations on fine tuning your VM.

To finally start the VM, run

vagrant up

The first time you run the command it is going to take some time since you do not have a locally available image of the Ubuntu 16.04 VM. Vagrant will download the VM from the Vagrant Cloud to your local system.

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/xenial64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/xenial64'
default: URL:
==> default: Adding box 'ubuntu/xenial64' (v20180406.0.0) for provider: virtualbox
default: Downloading:

At the end of the download process Vagrant will start the VM.

To access the Virtual machine, run

vagrant ssh


You need an SSH client for the previous command to work. Most Linux distributions come with an SSH installed. If you are using Windows as the guest operating system install MinGW or Cygwin or Git to obtain a command line SSH client. More information available here

You will be connected to the guest Virtual Machine over SSH as user vagrant. Vagrant provides all files next to your Vagrantfile in a folder called /vagrant at your VM.