Setup and Boxes
Vagrant reads its setting and instructions from Vagrantfile. It is generally present in its home directory. This file is created once you start initialize the vagrant.
Supposing you are in your root directory of vagrant. Run this to initialize your vagrant.
Now you will have a Vagrantfile in your root directory. Open the file in editor to start making changes for your virtual machine
sudo vi Vagrantfile
or you can use any editor of your choice.
Now that you have Vagrantfile initilized, now we have to add a box to vagrant. Once the box is added it can be reused.
You can view different types of boxes present on list of boxes on hashicorp.
For adding the box run this command
vagrant box add hashicorp/precise64
hashicorp/precise64 is the name of box you want to run in virtual machine. hashicorp/precise64 is standard ubuntu 12.04.
Now that you have added the box you want your Vagrantfile to use this box. Edit your Vagrantfile
Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" end
change the config.vm.box to the box you want to run. you can also define box version by using
config.vm.box_version = "1.1.0"
It will take some time and then you will have your virtual machine running.
- Starting and SSH into Box
- Syncing local folder to the virtual machine
- Setting up environment for the virtual machine
- Networking forwarding port to host machine and other options
- Sharing the Vagrant images
- Extra points and conclusion