Vagrant is a wrapper for VirtualBox. It allows you to interact with your virtual box using a Vagrantfile and a set of commands, similar to Docker.


Installing ΒΆ

  1. To use Vagrant, you will first need to install VirtualBox:​

  2. Install Vagrant from here:​

Getting Started & Basic Commands ΒΆ

To create a box:

vagrant init <BOX_NAME>

For example:

vagrant init ubuntu/trusty64

To run the box:

vagrant up

To shut down the box:

vagrant suspend

To resume the box:

vagrant resume

To remove the box permanently:

vagrant destroy

If you update your Vagrantfile and want to reload:

vagrant reload

SSH into Box ΒΆ

You can SSH into your box:

vagrant ssh

This will bring up a terminal that you can use. For example, you might want to install git:

sudo apt-get update
sudo apt-get install -y git

Vagrantfile ΒΆ

Memory and CPU Settings ΒΆ

To configure memory and CPU used by your virtual box:

config.vm.provider "virtualbox" do |vb|
    vb.memory = 2048
    vb.cpus = 4

Folder Settings ΒΆ

You will probably also want to use data from your local machine. To do this:

config.vm.synced_folder "path/to/local/folder", "path/to/vagrant/folder"

The path/to/local/folder can be absolute, or relative to the location of the Vagrantfile. The path/to/vagrant/folder is where you want the data to be added in your box.

Startup/Provision Settings ΒΆ

When you start your box, you can install packages/run commands:

config.vm.provision "shell", inline: <<-SHELL    
    apt-get update
    apt-get install -y apache2

If you have a lot of packages to install or commands to run, you may want to put them in a separate file:

config.vm.provision "shell", path: ""

Running MacOS ΒΆ

In order to run MacOS, you may need to reinstall.

  1. Clear csrutil and restart.

sudo su
csrutil clear

2. Uninstall from the official installer (you may have to re-download the installer if you deleted it, as the uninstall file is in there).

3. Reinstall.

4. Restart your computer.

5. Install Oracle VM VirtualBox Extension Pack

6. Install vagrant-vbguest:

vagrant plugin install vagrant-vbguest