This article is going to cover shortly how to add a Vagrant box from local or remote. The remote boxes are referred to the boxes needed to be installed via HTTP while the local boxes are boxes can be installed from the filesystem.

1. How to add a Vagrant box from local or remote

Let’s see the syntax of the below command:

As for the location of the box, there are 3 options for us:

We will go through 3 options step by step in the next sections.

2.1. Add a remote box using name

This is the easiest way to install a box. For example, let’s assume that we want to install Ubuntu 16 box, we can to go the publicly available catalog , search for the box by name and find a box named ubuntu/xenial64. And to add that remote box to our environment, we just need to issue the command:

Vagrant will download the box and install it automatically from the public catalog.

how to add a Vagrant box from local or remote

2.2. Add a remote box with URL

This way could be used when we want to add a box located at a specific URL and the box was not existed in the public catalog.

Let’s assume that we want to add a debian-jessie box from another website rather than the Vagrant public catalog.

2.3. Add a local box using path

This is a situation when we have a local box packaged by ourselves, or shared from our colleagues or even a box that was downloaded by ourselves. And below is the way how we can  add a local box.

2.3.1. On Windows

The below example will add the ubuntu16.xenial64.box box at the D:\VagrantBoxes directory. Note that we also specify the name of the box is: ubuntu/xenial64

An alternative way is to open the terminal, cd to the directory where the box is existing and install the box.

2.3.2. On Linux

This example will add the ubuntu/xenial64 box at the /data/VagrantBoxes directory.

Note that we have just named the box: ubuntu/xenial64.

2. Summary

We have learned how to add a Vagrant box from local or remote. Note that for local boxes, we should specify the box name for the command because the installation may not find the metadata of the local boxes.  In some cases, we also need to specify the hypervior provider with which the box should be used; otherwise, the default provider, VirtualBox will be used.

3. References

https://www.vagrantup.com/docs/getting-started/boxes.html

 

0 0 vote
Article Rating