如何使用 Hyper-V 作为提供程序删除缓存的不存在的 Virtualbox 机器?

How to remove cached non-existing Virtualbox machines, using Hyper-V as provider?

我在 Windows 10 Pro 下使用 Vagrant,首先使用 Virtualbox 提供程序并创建了几个盒子。然后因为我想测试 Docker for Win,所以我不得不切换到 Hyper V 并卸载 Virtualbox。一段时间后,我手动删除了一些 Virtualbox 机器或重新调整了文件夹的用途,因此它们中不再有 Vagrantfile。

当我尝试 运行 时
vagrant global-status --prune
或者
vagrant destroy -f XXXYYYZZZ
我收到此错误:
The provider 'virtualbox' that was requested to back the machine 'default' is reporting that it isn't usable on this system. The reason is shown below: Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed. Vagrant uses the VBoxManage binary that ships with VirtualBox, and requires this to be available on the PATH. If VirtualBox is installed, please find the VBoxManage binary and add it to the PATH environmental variable.
我明白 Vagrant 想说的是:安装 virtualbox 二进制文件,以便它可以管理这些盒子。但实际上没有 VM 开始,所以从注册表中删除它就足够了,为此不需要 Virtualbox。
在我的情况下,有没有办法从注册表中删除缓存的框?

vagrant 将其管理的机器列表保存在以下位置(即 Mac,您需要找到 windows,因为我不完全确定路径)

~/.vagrant.d/data/machine-index

在此文件夹下,您会找到一个 index 文件,其中列出了缓存中的所有机器。它是一个 JSon 文件,并且列出了机器的提供者,因此您可以删除任何不是 VirtualBox

的东西

当我尝试在我的 Windows 10 机器上使用 vagrant + virtual box 安装 Docker 时,我遇到了类似的情况。

我已经卸载了 virtual box,但是每次我尝试 运行 "vagrant up"

时仍然出现同样的错误

The provider 'virtualbox' that was requested to back the machine 'default' is reporting that it isn't usable on this system. The reason is shown below:

Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed. Vagrant uses the VBoxManage binary that ships with VirtualBox, and requires this to be available on the PATH. If VirtualBox is installed, please find the VBoxManage binary and add it to the PATH environmental variable.

所以下面的过程让我摆脱了它。

第 1 步:在 "config.vm.box"

行下方的 vagrantfile 中添加以下行
config.vm.define "hyperv"

第 2 步:从 powershell 或 cmd 启动你的 vagrant box 调用,如下所示

vagrant up --provider=hyperv

应该可以。经过这些步骤后,我得到了 vagrant 运行ning。 它必须是作为虚拟框保存在缓存或注册表中某处的提供程序。enter code here

来源:https://willmurphyscode.net/2017/01/16/a-very-simple-vagrant-deployment/