How do I remove all traces of a Vagrant box without having to go into the file system manually?
I am creating a custom box using Packer, building and destroying a lot of test cases. When finished with a test case, I run
vagrant destroy
The vagrant help
describes this command as
stops and deletes all traces of the vagrant machine
Everything seems well with the world. However, when I create a new box, after a brand new installation, I notice that my message of the day says the VM was created several days ago. It turns out boxes are (also) stored in .vagrant.d\boxes
. Vagrant is using those boxes rather than, or in addition to, the boxes created by Packer, which live in a completely different location.
The vagrant documentation for vagrant destroy
recommends using vagrant box remove
.
Now, there's still a box in .vagrant.d\boxes
directory. Using vagrant box remove
requires a "name".
If I run vagrant box list
, it says
There are no installed boxes! Use
vagrant box add
to add some.
Apparently Vagrant doesn't know about this other box. Yet if I run vagrant global-status
, I get an output like
id name provider state directory
-------------------------------------------------------------------------
47d1c7c default virtualbox poweroff C:/some/path
So, Vagrant can see some box. Trying to use vagrant box remove
, neither the "name" or "id" references work:
C:\some\path>vagrant box remove default
The box you requested to be removed could not be found. No
boxes named 'default' could be found.
C:\some\path>vagrant box remove 47d1c7c
The box you requested to be removed could not be found. No
boxes named '47d1c7c' could be found.
Of course, I can just delete the boxes by hand in .vagrant.d\boxes
.
It seems like my understanding of what Vagrant means by 'box', 'destroy', 'remove', and, well, almost all the terms involved here, isn't correct. I can't make sense of it all. There's a Vagrant VM directory which contains one box, but then there's the box Packer creates, and there's yet another box in .vagrant.d\boxes
. To destroy
a box removes some of the traces, but not all. The list
command sees some boxes but not others. It all appears very inconsistent.
I'm creating CentOS 7 guests on a Windows 7 host, if that matters.