Question

How should I use the command vagrant destroy?

In my VagrantFile I used vm.config.name = 'websvr' and when I open Virtualbox I can see websvr on the list of Vm's.

But whenever I use vagrant destroy websvr it returns:

The machine with the name 'websvr' was not found configured for this Vagrant environment.

How does vagrant destroy work?

Was it helpful?

Solution

It seems the item does not exist, but it appears in the list because it is present in the cache. Use vagrant global-status --prune to get rid of it.

See vagrant global-status documentation for more details.

OTHER TIPS

Lets try these action in command line

    1. Check available installed boxes by calling

      vagrant box list

    1. Find box id

      vagrant global-status --prune

    1. Select by id name of your box for destroying.

      vagrant destroy 1a2b3c4d

Thats all for you. Now you can destroy your vagrant box vagrant destroy xxxxxxx by this command.

Try running vagrant status first, which should list all of your VMs with their current status (running, not created, etc.)

The names of the VMs are displayed in the first column and are case sensitive.

For example, this is what the output of vagrant status looks like on my machine:

base                       not created (virtualbox)
git                        not created (virtualbox)
go                         not created (virtualbox)
dev_workstation            not created (virtualbox)
single_instance            not created (virtualbox)
metrics                    not created (virtualbox)

To completely clean VM and start from fresh - the below worked for me - basically combination of what others have said already.

  1. Check VM status with vagrant locally and destroy if exists - all done inside vagrant folder - MAKE SURE you are in the correct folder!

    $ vagrant status
    $ vagrant destroy
    $ rm -rf .vagrant
    
  2. Check VM status with vagrant globally and "destroy" if exists - can be done from anywhere

    $ vagrant global-status
    $ vagrant global-status --prune
    
  3. Check VM status with VirtualBox's perspective and unregister VM

    $ vboxmanage list vms   
    ### note down long id, eg. c43266e6-e22b-437a-8cc1-541b7ed5c4b
    
    $ vboxmanage unregistervm <long id> --delete
    
  4. Go back into appropriate vagrant folder and start VM

    $ vagrant up
    

To destroy the vagrant you may try these simple steps:

  1. You need to exit the ssh if you are already running vagrant ssh command you can type in exit to come out of vagrant ssh.
  2. Once you are out of vagrant type:
vagrant destroy -f.

If these don't work out for you you may try it using bash.

Jump into the project folder where your actual code resides. Right-click and press git bash here. You will see a bash window popping up so just type in the same command in bash window: vagrant destroy -f.

I hope these simple steps work out for you.

check the folder ./.vagrant/machines, and delete the ones you no longer need

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top