Part 4 – Add,Update and Remove a Box in Vagrant

In this post, lets see how we can add a box to the vagrant. Since we already added a Ubuntu machine in the last post, lets now try to add a CentOS box.

The command to add box is very simple,

vagrant box add “<catalog name>/URL/local path>

We can either add a box from your local file system if you have a custom image built for yourself or you can use a URL or use the public catalog name from Vagrant’s Atlas. I am going to use the Atlas here.

Navigate to the vagrant folder and use the command with catalog name centos/7

Since the catalog can work with multiple providers, it gives an option to enter your choice. As i am going to run them on a VirtualBox, i am gonna hit 2 here

2

This starts downloding the box and gives you an estimated time remaining. That’s it. You have now added a box to vagrant.

2

The added boxes, may have an updated version available on Atlas. To update to a newer available version, just use vagrant box update and it takes the same amount of time it took for adding the image because it just downloads the new image.

2.JPG

We can now check the boxes installed using vagrant box list

2

Did you see that guys? we actually have the new version installed as a new box. So to prune the old one, just remove the box using vagrant box remove, but since we have 2 versions of it, we must explicitly specify which version to be removed. See below.

1

We have just removed the old version and the list command does not show that VM now.

To disable vagrant boxes from checking for updates everytime they boot up, just use the below in the vagrantfile

config.vm.box_check_update = false

Hope this was informative. Thanks!

Part 1 – Install Vagrant on CentOS 7

Part 2 – Install VirtualBox on CentOS 7

Part 3 – Running a VM with Vagrant

Part 4 – Add,Update and Remove a Box in Vagrant

Part 5 – Running Multiple VMs using Vagrant

Advertisements

#add-box, #atlas, #remove-box, #update-box, #vagrant