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

时间:2016-05-25 21:59:09

标签: ubuntu vagrant localhost virtual-machine vagrant-provision

我今天开始加载我的dev / localhost环境,当我打开终端和cd ..到我的目标localhost文件夹时。我每天都做我做的事情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

如何让我的localhost再次运行?就像我的机器被删除或消失一样。

我的流浪档案:

# -*- 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

1 个答案:

答案 0 :(得分:3)

问题在于,当存在正确的实例时,vagrant在虚拟框中创建了另一个VM。

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

  1. 运行VBoxManage list runningvms并记下您要操作的VM的ID

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

  3. run vagrant command(halt / up)将运行预期的VM

  4. OLD ANSWER 如果您使用自定义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
      
    3. 如果要引用config.vm.box_url作为本地文件,则必须指定为框文件的路径(不是目录 - vagrant将为您解压缩)

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