Introduction
Vagrant is a tool for building and managing virtual machine environments.
Why do I use it?
To keep my local machine clean!!! <(▰˘◡˘▰)>
Installation
Install Homebrew
1
/usr/bin/ruby -e "$(curl -fsSL https:// raw.githubusercontent.com/Homebrew/install/master/ install)"
Install Virtualbox
1
brew cask install virtualbox
Install Vagrant
1
brew cask install vagrant
Commands
Basic Commands
Command | Usage |
---|---|
vagrant | display all available subcommands |
vagrant {subcommand} -h | display usage for subcommands |
vagrant box add | add vagrant box |
vagrant destroy | destroys all resources that were created (doesn’t remove box installed during vagrant up) |
vagrant halt | shuts down the running machine Vagrant is managing |
vagrant init | init current directory by creating Vagrantfile |
vagrant ssh | ssh into vm |
vagrant status | display state of vms in this directory |
vagrant up | creates and configures guest machines according to your Vagrantfile |
Common Commands
Command | Usage |
---|---|
vagrant box list | list all boxes |
vagrant box remove | remove a box |
vagrant global-status | show state of created machines for current user (vagrant status is only for current) |
vagrant provision | runs any configured provisioners against the running VM |
vagrant reload | vagrant halt; vagrant up. It can apply changes of Vagrantfile |
vagrant resume | resume machine that is vagrant suspend |
vagrant snapshot | similar as git stash, pop. Useful to try things and restore state |
vagrant suspend | suspend a VM instead of halt it. It no longer consume RAM. |
vagrant validate | validate Vagrantfile |
Cloud&Share Commands
Command | Usage |
---|---|
vagrant cloud | manage things related to Vagrant Cloud |
vagrant connect | enabling access to shared environments by vagrant share |
vagrant login | authenticate with protected boxes in HashiCorp’s Vagrant Cloud or using vagrant share |
vagrant share | share vagrant environment with anyone else in world |
Others
Command | Usage |
---|---|
vagrant package | package into a re-usable box |
vagrant plugin | manage plugins (we have a vagrant-libvirt plugin) |
vagrant port | displays the full list of guest ports mapped to the host machine ports |
vagrant powershell | this is only available for windows |
vagrant rdp | this is only available for windows |
vagrant ssh-config | This will output valid configuration for an SSH config file |
vagrant version | display version info |