如何启动打包器构建的本地VM?

时间:2015-06-17 14:19:10

标签: vagrant virtual-machine packer

我是包装工的新手。 首先,我尝试构建:https://github.com/shiguredo/packer-templates/tree/develop/ubuntu-14.04,工作正常。但是当我想通过vagrant up将其收起来时,我收到以下错误:

Vagrant environment or target machine is required to run this
command. Run `vagrant init` to create a new Vagrant environment. Or,
get an ID of a target machine from `vagrant global-status` to run
this command on. A final option is to change to a directory with a
Vagrantfile and to try again.

调用vagrant init后,会创建一个看起来像默认配置文件的配置文件。但仍有错误:

Bringing machine 'default' up with 'parallels' provider...
==> default: Box 'base' could not be found. Attempting to find and install...
    default: Box Provider: parallels
    default: Box Version: >= 0
==> default: Adding box 'base' (v0) for provider: parallels
    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 /Downloads/packer-templates-develop/ubuntu-14.04/base

如何在本地启动我的打包程序生成的VM? 是手动跟踪Vagrantfile的唯一解决方案吗?

编辑:

如果我致电vagrant init myNewlyCreatedBox.box 然后,vagrant会尝试启动虚拟机,但

Failed to mount folders in Linux guest. This is usually because
the "prl_fs" file system is not available. Please verify that
Parallels Tools are properly installed in the guest and
can work properly. If so, the VM reboot can solve a problem.
The command attempted was:

mount -t prl_fs -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t prl_fs -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

1 个答案:

答案 0 :(得分:2)

这些模板会为您生成一个Vagrant框。如果该过程成功完成,您应该拥有ubuntu-14-04-x64-virtualbox.box文件指定的ubuntu-14-04-x64-vmware.boxtemplate.json文件。要在Vagrant中使用这些新创建的框,您需要将与您的特定管理程序相对应的框添加到Vagrant通过以下方式了解的框列表中:

vagrant box add <nameToReferToBox> <pathToBoxYouJustCreated>

例如

vagrant box add ubuntu-14-04-x64 ubuntu-14-04-x64-virtualbox.box

然后,要创建该框(VM)的实例,您只需创建一个针对刚导入的新框的Vagrant文​​件:

vagrant init ubuntu-14-04-x64

然后根据基本框启动VM:

vagrant up