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
This starts downloding the box and gives you an estimated time remaining. That’s it. You have now added a box to vagrant.
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.
We can now check the boxes installed using vagrant box list
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.
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!