ubuntu - vagrant 和我的虚拟机 - vagrant 重新加载 - 默认 : VM not created. 继续

标签 ubuntu vagrant localhost virtual-machine vagrant-provision

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

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

然后我尝试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

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

我的 Vagrant 文件:

# -*- 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 在虚拟框中创建了另一个虚拟机,而正确的实例存在。

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

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

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

  3. 运行 vagrant 命令(halt/up)将操作预期的虚拟机

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

  1. 将盒子添加到 vagrant

    vagrant box add <name of your box : base> <path to the box file>
    
  2. 使用此框初始化和向上 Vagrant

    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>"

关于ubuntu - vagrant 和我的虚拟机 - vagrant 重新加载 - 默认 : VM not created. 继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37448343/

相关文章:

c++ - Apache 交叉编译错误./gen_test_char : cannot execute binary file

vagrant - Vagrant 配置程序清理任务的语法?

node.js - 本地主机 3000 和 5000 之间的区别?

ssh - 打包后 Vagrant 身份验证失败 - 私钥丢失

xampp - 错误启动 "XAMPP"堆栈另一个实例似乎正在 PID 455 运行

ruby-on-rails - 运行 "rails server"时,为什么我的本地主机拒绝在 Chrome 和 Firefox 上连接?

ubuntu - 在 Ubuntu 'Jaunty' 上构建 GD 的问题

postgresql - Ubuntu 18.04 Postgresql Client not installed 错误解决方法

c - 打印链接列表时出现意外输出

python - 如何响应 os.system 中的提示?