vagrant init ubuntu/xenial64
并启动它:
vagrant up --provider virtualBox
ssh-ing之后,我找不到文件夹/流氓
我做错了什么?
根据documentation应该有/ vagrant文件夹:
By default,Vagrant will share your project directory (the directory
with the Vagrantfile) to /vagrant.
这是一个screenshot,显然没有/ vagrant文件夹
我的主机环境是:
> windows 7
> Vagrant版本1.8.1
> VBox版本5.0.20r106931
这是我的Vagrant文件:
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure(2) do |config| config.vm.Box = "ubuntu/xenial64" config.vm.provision "shell",path: "provision.sh" config.vm.provider "virtualBox" do |vb| # Display the VirtualBox GUI when booting the machine vb.gui = true # Customize the amount of memory on the VM: vb.memory = "4096" vb.cpus = "2" # Hack for nom global install # https://github.com/npm/npm/issues/7308 vb.customize ["setextradata",:id,"VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant","1"] end end
这里是我的配置文件:
echo "------------------------------" echo "--- Updating packages list ---" echo "------------------------------" apt-get -y update echo "-----------------------" echo "--- Installing curl ---" echo "-----------------------" apt-get -y install curl echo "----------------------" echo "--- Installing git ---" echo "----------------------" apt-get -y install git echo "-----------------------------" echo "--- Installing python-pip ---" echo "-----------------------------" apt-get -y install python-pip yes | pip install --upgrade pip echo "--------------------------" echo "--- Installing node.js ---" echo "--------------------------" apt-get -y install nodejs echo "----------------------" echo "--- Installing npm ---" echo "----------------------" apt-get -y install npm
这个问题终于在版本v20160921.0.0及更高版本的官方16.04 vagrant Box中修复了.之前的版本v20160909.0.0也是固定的,但有另一个无关的问题,正如Poma在评论中指出的.
您可以使用以下命令下载新版本,并将旧的VM实例替换为新版本.但是,升级包将擦除您的原始VM实例.
vagrant Box update
如果您不想因为某些原因擦除虚拟机,您仍然可以在下面应用我的原始修复程序.
原帖:
显然官方的ubuntu / xenial64图像是破碎的,如this bug report on launchpad所示.
这里引用路易斯·扎克曼(Louis Zuckerman)的评论,其中所有的问题仍然是从我所说的版本20160627.0.0的版本仍然不固定的:
There are a number of issues with the official vagrant Box for xenial:
- necessary packages are missing (synced folders not working,no config management)
- default /vagrant synced folder is disabled
- vm name is static,so you can only have one instance of the Box on a host
[…]
这些步骤为我解决了问题1和2:
> ssh进入框,并手动安装缺少的客人添加
vagrant ssh sudo apt-get install virtualBox-guest-utils exit
>手动添加丢失的挂载点到您的Vagrantfile
config.vm.synced_folder ".","/vagrant/" # fix broken ubuntu/xenial64 image
要修复第三个问题,您必须通过向虚拟文件添加VirtualBox的提供程序特定选项,手动提供一个唯一的名称.
config.vm.provider "virtualBox" do |vb| vb.name = "This_Name_Is_Unique_For_This_Machine" end