Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download vagrant box file locally from atlas and configuring it

I want to download a vagrant box file from Atlas for using it later locally with my vagrant file. How can I do this, and how can I configure it?

like image 498
Muhammad Raihan Muhaimin Avatar asked Feb 08 '15 21:02

Muhammad Raihan Muhaimin


People also ask

How do I download a vagrant box?

Vagrant will prompt you to select a provider. Type 2 and press Enter to select Virtualbox. This will download the box named hashicorp/bionic64 from HashiCorp's Vagrant Cloud box catalog, where you can find and host boxes. Boxes are globally stored for the current user.

Where does vagrant store box files?

As mentioned in the docs, boxes are stored at: Mac OS X and Linux: ~/. vagrant. d/boxes.


3 Answers

To download a file you have to add version and provider in the URL. For example for downloading trusty64 First you need its URL which is https://app.vagrantup.com/ubuntu/boxes/trusty64/

then you have to add version and provider afterwards, for our example the download URL would be.

https://app.vagrantup.com/ubuntu/boxes/trusty64/versions/20180206.0.0/providers/virtualbox.box

Then you have to add it locally from your vagrant file.

To add it locally to vagrant file use the following command

vagrant box add foo-box /path/to/vagrant-box.box
vagrant init foo-box
vagrant up

This will create the vagrantfile and you can configure the vagrant file.

like image 128
Muhammad Raihan Muhaimin Avatar answered Oct 16 '22 20:10

Muhammad Raihan Muhaimin


However, this will add the box as version 0.

○ → vagrant box add ubuntu/trusty64 ~/Downloads/trusty-server-cloudimg-amd64-vagrant-disk1.box 
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu/trusty64' (v0) for provider: 
    box: Unpacking necessary files from: file:///Users/ram/Downloads/trusty-server-cloudimg-amd64-vagrant-disk1.box
==> box: Successfully added box 'ubuntu/trusty64' (v0) for 'virtualbox'!

vagrant does not allow to specify a version number of the manually added box

○ → vagrant box add ubuntu/trusty64 ~/Downloads/trusty-server-cloudimg-amd64-vagrant-disk1.box --box-version 20151021.0.0
==> box: Box file was not detected as metadata. Adding it directly...
You specified a box version constraint with a direct box file
path. Box version constraints only work with boxes from Vagrant
Cloud or a custom box host. Please remove the version constraint
and try again.

To update the version number of the box, change the folder name '0' in ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-trusty64/0 to the version number you downloaded. For example '20160120.0.0'

 |2.2.3| MacBook-Pro in ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-trusty64
○ → mv 0 20160120.0.0

now you are all set to update the version next time with vagrant command too

○ → vagrant box list
ubuntu/trusty64 (virtualbox, 20160120.0.0)
like image 28
Ram on Rails React Native Avatar answered Oct 16 '22 22:10

Ram on Rails React Native


I faced the same issue not being able to download from script. So manually downloaded the box and added to vagrant as below,

you can get versions you want from here - https://atlas.hashicorp.com/ubuntu/boxes/precise64

wget https://atlas.hashicorp.com/ubuntu/boxes/precise64/versions/20160818.0.0/providers/virtualbox.box

cd my_vagrant_project
vagrant box add precise64 ~/Downloads/precise-server-cloudimg-amd64-vagrant-disk1.box

vagrant init precise64
vagrant up
like image 4
prayagupa Avatar answered Oct 16 '22 22:10

prayagupa