5 Vagrant Commands You Need To Know

In this article, I will point out five commands that every Vagrant user needs to know.

Vagrant is a favorite among DevOps professionals as it provides a great way to great re-usable and identical test environments. The Vagrant CLI is very easy to use and provides users a way to manage their Vagrant environment efficiently.

1 – Vagrant Init

To understand Vagrant, you first need to understand one of the basic building blocks – Vagrantfile. A Vagrantfile is basically a configuration file that describes an environment. It will include things like the boxes used, networking, CPU and memory, providers used, shell scripts to run for provisioning among others.

In this example, I want to create a very basic Vagrantfile based on a box used from Vagrant Cloud. To do this I simply run vagrant init with the box address.

First, I will create a directory:

Next, lets cd into that directory

Here, I will use vagrant init and the –m option which means I will not add any helper comments into my Vagrantfile:

Finally let’s look into the Vagrantfile, which as we see just specifies the box I will be using:

Just like that I have enough to boot up a Vagrant box on my local machine.

2 – Vagrant Box

The vagrant box command allows the user to manage the boxes on their local machine. This includes adding, removing, listing and updating. For instance, to view the boxes I have installed on my machine I would run vagrant box list:

If I want to add a box, logically I use vagrant box add. Here I want to download and install a CentOS box for the virtualbox provider:

Read more at ipswitch.com

Leave a Reply

Your email address will not be published. Required fields are marked *