All notes
Vagra

Commands

Intro


vagrant init hashicorp/precise64
vagrant up

# You will be in /home/vagrant:
vagrant ssh

vagrant destroy

# To completely remove the box file
vagrant box remove

Features

Synced folders

By default, Vagrant shares your project directory to the /vagrant directory in your guest machine.

init


# Place a Vagrantfile in your current directory.
vagrant init

box

Base images are known as "boxes" in Vagrant.


# Download the box named "hashicorp/precise64" from vagrantup.com.
vagrant box add hashicorp/precise64

reload


# Reload Vagrantfile.
vagrant reload

# Quickly restart your virtual machine, skipping the initial import step.
vagrant reload --provision

share


vagrant share
# default: Creating Vagrant Share session...
# default: HTTP URL: http://b1fb1f3f.ngrok.io

teardown-related


vagrant suspend
vagrant halt
vagrant destroy # "vagrant up" has to reimport the machine and re-provision it.

up


vagrant up --provider=vmware_fusion

vagrant up --provider=aws

Vagrantfile


Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
  config.vm.box_version = "1.1.0"

  # Run this shell script when setting up our machine:
  config.vm.provision :shell, path: "bootstrap.sh"

  # Port forwarding
  config.vm.network :forwarded_port, guest: 80, host: 4567
end

Providers

Docker

vagrantup.com: docker.