Vagrant创建基本框

时间:2017-09-01 22:47:14

标签: ubuntu vagrant virtualbox

SO 许多关于此的文章无效或无法还原错误配置。也许删除所有Box并重新开始会有所帮助,但Vagrant说即使在确定使用

之类的东西之后也无法找到/销毁它们
vagrant box list

我试图实现这样一个简单的要求 - 使用Ubuntu服务器LTS,设置Nginx,PHP,MySQL。 配置Nginx以显示测试HTML和PHPinfo.php页面。

打包该框,以便我可以重用已设置并正常工作的现有Web开发虚拟机。

Vagrant不断忽略新打包的盒子并加载“默认”,尽管编辑了Vagrantfile。

我没有做任何时髦的事情,只是尝试从官方的ubuntu / xenial64创建一个基本框,然后再浪费另外两天,Vagrant包没有私钥/公钥而变得无用。

目前的资料来源如下,但是关于包装可重复使用的盒子的文件记录很少,我开始认为Vagrant无法使用。

https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one

#minimise and delete junk
sudo apt-get clean;
sudo dd if=/dev/zero of=/EMPTY bs=1M;
sudo rm -f /EMPTY;
cat /dev/null > ~/.bash_history && history -c && exit;

#package it
vagrant package --output lnmp_1604_70.box

#add box
vagrant box add lnmp_1604_70_v01 lnmp_1604_70.box

vagrant init lnmp_1604_70_v01

# IMPORTANT - do this before first vagrant up

config.vm.box = "lnmp_1604_70_v01"
config.ssh.insert_key = false;# in Vagrantfile

# It will keep the insecure key in place while prepping your VM for packaging
# If the key has already been replaced you can restore the default one by editing "~vagrant/.ssh/authorized_keys" and replacing it with # the insecure public key at https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub

Vagrant 1.9.8

1 个答案:

答案 0 :(得分:0)

The procedure described at How to Create a Vagrant Base Box from an Existing One works perfectly on my box.

I think that after

vagrant box add lnmp_1604_70_v01 lnmp_1604_70.box

you have to run

vagrant init lnmp_1604_70_v01

instead of, as you wrote in your question,

vagrant init lnmp_1604_70