vagrant 和我的虚拟机 - vagrant reload - 默认值:未创建 VM。继续

vagrant and my virtual machine - vagrant reload - default: VM not created. Moving on

我今天去加载我的 dev/localhost 环境,当我打开终端和 cd .. 到我的目标本地主机文件夹时。我做我每天做的事,我 vagrant reload。通常我的本地主机在输入密码后大约 30 秒内启动。

今天,当我尝试 vagrant reload 时,我收到消息“默认值:VM 未创建。继续...

然后我尝试 vagrant up 看看它是否由于某种原因而关闭,我收到了错误消息

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'base' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'base' (v0) for provider: virtualbox
    default: Downloading: base
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

Couldn't open file /Users/me/Documents/Development/website/www/base

在浏览器方面,页面看起来像这样:

Index of /

[ICO]   Name    Last modified   Size    Description
Apache/2.2.22 (Ubuntu) Server at dev.webite.com Port 80

如何重新获取本地主机 运行?就像我的机器被删除或消失了一样。

我的流浪档案:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!

Vagrant.configure(2) do |config|

  config.vm.box = "magento"

  config.vm.network :forwarded_port, guest: 80, host: 8085

  # config.vm.network :public_network
  config.vm.network "private_network", ip: "192.168.19.88"

  config.vm.synced_folder ".", "/vagrant", type: "nfs"

  config.vm.provider :virtualbox do |vb|
    #vb.gui = true
    vb.customize ["modifyvm", :id, "--memory", "4096"]
    vb.cpus = 4

  end

end

问题是 vagrant 在 vi​​rtual box 中创建了另一个 VM,而正确的实例存在。

为了能够从 vagrant 操作正确的虚拟机 VM,请按照以下步骤操作:

  1. 运行 VBoxManage list runningvms 并记下你要操作的虚拟机ID

  2. 编辑文件 .vagrant/machines/default/virtualbox/id 并设置在上述步骤中找到的 ID

  3. 运行 vagrant 命令(halt/up)将运行预期的 VM

旧答案 如果您使用自定义 base 框,可能更好:

  1. 将盒子添加到 vagrant

    vagrant box add <name of your box : base> <path to the box file>
    
  2. 用这个盒子初始化和升级流浪者

    vagrant box init <name of your box : base>
    vagrant up
    

如果你想将 config.vm.box_url 引用为本地文件,你必须指定为 box 文件的路径(不是目录 - vagrant 将为你解压缩)

config.vm.box_url = "file://<path to a box file>"