
What is Vagrant? Why should we use vagrant? what is a vagrant box and file?
What is a vagrant:
It is a software product that builds and maintains virtual software
development environments. Indeed, the tool is considered to offer one
of the fastest and easiest ways to create a virtual environment
What benefits of using vagrant:
Vagrant provides easy-to-configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team
Vagrant Box:
Vagrant boxes are VM images that already have the OS and software installed in them. We just need to download these boxes from the vagrant
cloud by using our Vagrant CLI.Once the box is downloaded you can
create as many VM’s from them.
We can download boxes from this url : https://app.vagrantup.com/boxes/search
Vagrant file:
Step by step to create VM with vagrant:
1. For using Vagrant you need to install Vagrant to your computer. To install Vagrant you can follow the link: https://developer.hashicorp.com/vagrant/downloads
2. After successful installation you can verify installation using this command to your terminal: vagrant
3. Here first download the box using this command: vagrant box add kalilinux/rolling
4. Then write the below command. It takes laser time because already we have downloaded it from the cloud and stored it on the local machine. the command is: vagrant init kalilinux/rolling
or you can create a minimal Vagrantfile (no comments or helpers): vagrant init -m kalilinux/rolling
or create a new Vagrantfile, overwriting the one at the current path: vagrant init -f kalilinux/rolling
5. Start virtual machine: vagrant up
Also some commands:
==> List the downloaded boxes: vagrant box list
==> Remove box: vagrant box remove box_name
==> SSH into the virtual machine: vagrant ssh
==> Halt virtual machine: vagrant half
==> Destroy your virtual machine: vagrant destroy
Tips: After destroying Vagrant the source code and the content of the data directory will remain unchanged. Only the Virtual Box machine instance will be destroyed. You can build your machine again with the ‘vagrant up’ command.