Skip to content

Instantly share code, notes, and snippets.

@edelans
Forked from wpscholar/vagrant-cheat-sheet.md
Last active January 8, 2016 12:32
Show Gist options
  • Save edelans/5d90d049f489393e5b1e to your computer and use it in GitHub Desktop.
Save edelans/5d90d049f489393e5b1e to your computer and use it in GitHub Desktop.
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

# Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
  • vagrant provision -- forces reprovisioning of the vagrant machine
  • vagrant reload -- The equivalent of vagrant halt followed by vagrant up
  • vagrant reload --provision -- Restart the virtual machine and force provisioning

# Getting into a VM

  • vagrant ssh -- connects to machine via SSH
  • vagrant ssh boxname -- If you give your box a name in your Vagrantfile, you can ssh into it with boxname. Works from any directory.

# Stoping a VM

  • vagrant halt -- stops the vagrant machine

# Cleaning up a VM

  • vagrant destroy -- stops and deletes all traces of the vagrant machine
  • `vagrant destroy -f -- same as above, without confirmation

Tips

  • vagrant -v -- Get the vagrant version
  • vagrant status -- outputs status of the vagrant machine1
  • vagrant global-status -- outputs status of all vagrant machines
  • vagrant suspend -- Suspends a virtual machine (remembers state)
  • vagrant resume -- Resume a suspended machine (vagrant up works just fine for this as well)
  • vagrant provision --debug -- Use the debug flag to increase the verbosity of the output
  • vagrant push -- Yes, vagrant can be configured to deploy code!
  • vagrant up --provision | tee provision.log -- Runs vagrant up, forces provisioning and logs all output to a file

Boxes

  • vagrant box list -- See a list of all installed boxes on your computer
  • vagrant box add -- Download a box image to your computer

# Plugins

  • vagrant plugin hostsupdater : $ vagrant plugin install vagrant-hostsupdater to update your /etc/hosts file automatically each time you start/stop your vagrant box.

# Database administration

  • If you want to inspect your VM database directly from your local pgadmin, check this out !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment