I'm reading the Vagrant docs on boxes and not understanding the difference between:
vagrant box add hashicorp/precise32
; vs.vagrant init hashicorp/precise32
The latter fetches the hashicorp/precise32
box from a remote catalog, and then creates a Vagrantfile
for spinning up an instance of that box. But I don't see how that's different than the box add
method.
So I ask: What's the difference between these two commands and when is it appropriate to use each of them?
You can add a box to Vagrant with vagrant box add . This stores the box under a specific name so that multiple Vagrant environments can re-use it.
Command: vagrant init [name [url]] This initializes the current directory to be a Vagrant environment by creating an initial Vagrantfile if one does not already exist. If a first argument is given, it will prepopulate the config.
Vagrant is able to define and control multiple guest machines per Vagrantfile. This is known as a "multi-machine" environment. These machines are generally able to work together or are somehow associated with each other.
1 - Vagrant Init 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. `vagrantup.com` for more information on using Vagrant.
vagrant box add hashicorp/precise32
just download the box image into your vagrant application while:
vagrant init hashicorp/precise32
make a vagrant file in current directory. if vagrant box image hasn`t been downloaded before. then it try to download the vagrant box image.
in the scenario which vagrant box has been added then we want to init a vagrant file. in shell we can get an name auto complete with Tab button, because it knows the vagrant image already.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With