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



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

当我尝试运行
vagrant global-status --prunevagrant 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 二进制文件,以便它可以管理盒子。但实际上没有虚拟机可以开始,所以从注册表中删除它应该足够了,为此不需要 Virtualbox。
在我的情况下,有没有办法从注册表中删除缓存的框?

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

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

在此文件夹下,您将找到一个index文件,该文件将列出缓存中的所有计算机。 这是一个JSon文件,列出了机器的提供程序,因此您可以删除任何不是VirtualBox的内容。

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

我已经卸载了虚拟盒子,但是每次我尝试运行"流浪者"时,都会继续出现相同的错误

请求支持计算机的提供程序"虚拟盒" "默认"表示报告它在此系统上不可用。原因 如下所示:

流浪者无法检测到虚拟盒子!确保VirtualBox正确 安装。Vagrant 使用附带的VBoxManage二进制文件 VirtualBox,并要求它在PATH上可用。如果 VirtualBox已安装,请找到VBoxManage二进制文件并添加 它到 PATH 环境变量。

所以下面的过程把我从中拯救出来。

第 1 步:在 vagrantfile 中添加以下行"config.vm.box">

config.vm.define "hyperv"

第 2 步:从 Powershell 或 cmd 开始您的流浪盒子调用,如下所示

vagrant up --provider=hyperv

它应该有效。我让流浪汉在这些步骤之后运行。 它必须是在缓存或注册表中的某个地方保存为虚拟框的提供程序。enter code here

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

最新更新