Getting started With Vagrant and VirtualBox on OS X

Vagrant is an awesome free tool for versioning environments. Basically with it you can easily get up and running virtual machine image within seconds. It's working beautifully with Oracle's free VirtualBox.

To install Vagrant and VirtualBox on Mac OS X, simply start by installing brew and cask with these 3 commands:

ruby -e "$(curl -fsSL"

brew tap caskroom/cask

brew install brew-cask

Then, install Vagrant and VirtualBox via brew and cask:

brew cask install vagrant virtualbox

After that you can simply check installed versions:

vagrant -v && vboxmanage -v

Add CentOS image to Vagrant (you can choose other than CentOS, here's a list of others):

vagrant box add centos

To start your virtual machine, create a directory, change to it and initialise Vagrant box:

mkdir centos && cd centos && vagrant init centos

After that, you can start your box and SSH into it:

vagrant up

vagrant ssh

That's it! You've got CentOS VM running with Vagrant! You can package your vagrant box using vagrant package --output command.

Other useful Vagrant and VirtualBox commands can be listed with vagrant -h and vboxmanage -h | less.