So I am a beginner when it comes to vagrant. While going through the online content and documentation related to it, I came across 3 vagrant commands namely, \'destroy\', \'
(Kevin answered correctly, +1! I just provide a bit more information for vagrant beginner)
First you need to understand how vagrant works.
When you create a vagrant environment you will create a vagrant file (you can use the command vagrant init bento/ubuntu-16.04
) - the Vagrantfile
will look like (reduced to minimal)
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-16.04"
end
when you will spin up vagrant (vagrant up
) to run a VM, what it will do is :
$HOME/.vagrant.d/boxes
folder and can be used for any other VagrantfileYou can download any number of box and store them in your .vagrant.d
folder and you can see the list of available box running
$ vagrant box list
You can see the VM that vagrant currently managed by running
$ vagrant global-status
Now to answer your question, the command will have impact on different level:
vagrant halt
You understand correctly - you can review my previous answer for further reading on In Vagrant which is better out of halt and suspend?
vagrant destroy
This command destroys all VM resources (but not any vagrant resources) so all the VirtualBox VM files are destroyed but the box remained untouched.
You can check by running vagrant box list
after you run vagrant destroy
on a VM, all boxes remain untouched.
vagrant remove
This command remove (destroy) the vagrant resources so if you want to create a new VM later against the base box, vagrant would need to re-download from internet.
Note that after you have created the VM, you can remove the box and vagrant will still work correctly so vagrant remove
has no effect on the VirtualBox resources and all VMs remain untouched
Note on box usage:
you can have multiple versions of the same box
$ vagrant box list
bento/ubuntu-16.04 (vmware_desktop, 2.3.0)
bento/ubuntu-16.04 (vmware_desktop, 2.3.7)
you can have same version of box for different providers
$ vagrant box list
bento/ubuntu-16.04 (virtualbox, 201708.22.0)
bento/ubuntu-16.04 (vmware_desktop, 2.3.0)
bento/ubuntu-16.04 (vmware_desktop, 2.3.7)
Welcome to SO! This is a great question. To clarify vagrant box remove YOUR_BOX_NAME
is for removing a box completely such as hashicorp/precise64
where indeed you have to re-download it to use it. Now vagrant destroy
simply destroys the Virtual Machine so it will not show up in your manager, for example if you use Oracle VM Manager. I hope this provides clarification.