Up and Running With Vagrant
Vagrant is an open-source software product for building and maintaining portable virtual software development environments. Vagrant is written is ruby and is maintained by Hashicorp. It helps you build and launch reusable virtual machines using Vagrantfile.
Install Vagrant on Mac
To install vagrant on mac you can just simply run the following command. In order to successfully use vagrant, you need to first install virtualbox.
Install virtualbox:
$ brew cask install virtualboxInstall vagrant:
$ brew cask install vagrantFor other platform please refer this link.
Now you have vagrant installed on your laptop. Let’s launch your first virtual box.
Create Vagrantfile
Vagrantfile is configuration file for your virtual machine this helps to build and manage virtual machine.
Let’s create our first vagrantfile. Create a file named Vagrantfile in your ~/Vagrantfiles/ubuntu/.
Vagrant.configure(2) do |config|config.vm.box = "ubuntu/xenial64"config.vm.network "forwarded_port", guest: 80, host: 9000config.vm.provider "virtualbox" do |vb|vb.memory = 1024endconfig.vm.provision 'shell', inline: <<-SHELLecho 'ubuntu:ubuntu' | sudo chpasswdSHELLend
In the above example we are creating a ubuntu machine with 1024 mb ram and with username and password ubuntu. Once this is done, let’s start our virtual machine.
Getting ubuntu machine up and running
In order to get your virtual machine up and running you need to just go to the directory under which the vagrantfile is situated.
$ cd ~/Vagrantfiles/ubuntu/
$ vagrant upBy now you will have your ubuntu machine up and running. To use your machine you need to simply ssh into the machine using the following command.
$ vagrant sshThis is it for now. To know more about vagrant please stay tuned to my blogs.
