Skip to content

Instantly share code, notes, and snippets.

@dcuadraq
Last active August 7, 2016 19:58
Show Gist options
  • Save dcuadraq/641b97d07163873f333e90848ab2d8e8 to your computer and use it in GitHub Desktop.
Save dcuadraq/641b97d07163873f333e90848ab2d8e8 to your computer and use it in GitHub Desktop.
Vagrant commands

#Vagrant

Creates and downloads if necesary a vm with Ubuntu 12.04 LTS

vagrant init hashicorp/precise32

Runs the VM of current directory

vagrant up

To check the status of a vm:

vagrant status

To stop the VM

vagrant halt

Stops the VM and starts it again

vagrant reload

Suspend VM stores guest RAM on host disk and frees the resources

vagrant suspend

To restore the suspended VM

vagrant resume

Connects to current directory vm

vagrant ssh

To delete the VM

vagrant destroy

Prints current running vms

vboxmanage list runningvms

##Vagrantfile To not run headless, uncomment

vb.gui = true

This will open a Virtual Box window when running the vm, the user and password are vagrant

To forward ports from guest to host

config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 80, host: 8080, id: "nginx", guest_ip: "X.X.X.X", host_ip: "X.X.X.X", protocol: "udp", auto_correct: true

Auto correct parameter fixes protocol collisions

###Provisioning To declare provisions on Vagrant file:

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

Provisions are called on VM creation, but not subsecuent calls (ups), to force them use:

vagrant provision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment