Reputation: 6831
I am confused with vagrant destroy
command.
The output of vagrant status
is
Current machine states:
default running (virtualbox)
But I have two vagrant VMs running in Virtual box
MacBook-Pro:server john$ vboxmanage list runningvms
"john-servers_default_1415665580149_91312" {114ad904-8629-4c4a-9344-d685c78a8228}
"test" {a6be5689-0ac3-4ac7-845d-97f2f4022cd9}
Now when I do vagrant destroy
, it says do you want to destroy deafult VM
Now I am not sure which machine it will destroy. I am inside test
VM but I don't want to take risk.
I tried this vagrant destroy test
or vagrant destroy a6be5689-0ac3-4ac7-845d-97f2f4022cd9
but that didn't work
What is the safe way to delete VM?
Upvotes: 1
Views: 2371
Reputation: 96
To destroy test
VM, cd
into the test folder and enter vagrant destroy
- this will destroy the vagrant environment within this directory. After it is destroyed, the default
provider will still be shown when you enter vagrant status
, together with a not created (virtualbox)
status.
vagrant status
only shows one vagrant VM running in virtualbox because this command only shows the state of the underlying guest machine within that directory.
In order to see all vagrant environments, enter vagrant global-status --prune
- this brings up the state of all the active vagrant environments no matter what directory you run this command from. You can even destroy a VM that's outside of your current directory by typing vagrant destroy ID_TAG
by copying the ID tagged to the unwanted VM.
If you are still unsure if the right VM is destroyed, input vagrant halt
within the test
directory and test if the right VM is being halted. This is at the very least a reversible action in case the wrong VM is selected. But the initial solution vagrant destroy
within the test
directory should do the trick.
Upvotes: 8
Reputation: 1567
vagrant destroy
would remove, in your case, the "john-servers_default_1415665580149_91312" VM.
Vagrant look the VM ID in the directory containing the Vagrantfile in .vagrant/machines/default/virtualbox/id
If you want to remove the "test" VM, you can use VBoxManage.
VBoxManage unregistervm a6be5689-0ac3-4ac7-845d-97f2f4022cd9 –delete
Keep in mind that the -delete
flag will remove all disks associated with this VM
Upvotes: 1