我正在学习Udacity课程,他们让我安装Vagrant。但是由于。box文件的大尺寸,我首先从其他网络下载到本地,我得到了这个tar文件trusty-server-cloudimg-i386-vagrant-disk1.tar
。他们让我下载他们的文件夹fullstack
。该文件夹由以下结构组成:
|--fullstack
|--vagrant
|--.vagrant
|--catalog
|--forum
|--forum.py
|--forum.sql
|--forumdb.py
|--tournament
|--tournament.py
|--tournament.sql
|--tournament_test.py
|--pg_config
|--Vagrantfile
你可以从这个链接看到他们是怎么做的。现在,当我在git bash
上使用vagrant up
时,前往fullstack/vagrant
的位置,以下代码正在启动:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty32' could not be found. Attempting to find and in
stall...
default: Box Provider: virtualbox
defa
ult: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/trusty32'
default: URL: https://atlas.hashicorp.com/ubuntu/trusty32
==> default: Adding box 'ubuntu/trusty32' (v20150818.0.0) for provider: virtualb
ox
现在,正如您在向下的代码中看到的,它试图从在线下载。box文件,我已经在本地下载,并且我在我的驱动器上。我想编辑一些配置文件,这样当我使用vagrant up
时,它应该使用本地文件trusty-server-cloudimg-i386-vagrant-disk1.tar
文件来安装,不应该去下载在线文件
default: Downloading: https://atlas.hashicorp.com/ubuntu/boxes/trusty32/versions/20150818.0.0/providers/virtualbox.box
==> default: Box download is resuming from prior download progress
default: Progress: 0% (Rate: 13410/s, Estimated time remaining: 5:35:56))
如果还需要一些信息,请在评论中问我,我会更新我的问题。
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", path: "pg_config.sh"
# config.vm.box = "hashicorp/precise32"
config.vm.box = "ubuntu/trusty32"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 5000, host: 5000
end
pg_config.sh:
apt-get -qqy update
apt-get -qqy install postgresql python-psycopg2
apt-get -qqy install python-flask python-sqlalchemy
apt-get -qqy install python-pip
pip install bleach
pip install oauth2client
pip install requests
pip install httplib2
su postgres -c 'createuser -dRS vagrant'
su vagrant -c 'createdb'
su vagrant -c 'createdb forum'
su vagrant -c 'psql forum -f /vagrant/forum/forum.sql'
vagrantTip="[35m[1mThe shared directory is located at /vagrantnTo access your shared files: cd /vagrant(B[m"
echo -e $vagrantTip > /etc/motd
当我尝试这样添加时,我得到以下错误:
$ vagrant box add mybox C:UsersRahulDownloadstrusty-server-cloudimg-i386-va
grant-disk1.tar
c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/generic.rb:214:in `initialize':
the scheme file does not accept registry part: C:UsersRahulDownloadstrusty-serv
er-cloudimg-i386-vagrant-disk1.tar (or bad hostname?) (URI::InvalidURIError)
from c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/common.rb:218:in `
new'
from c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/common.rb:218:in `
parse'
from c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/common.rb:747:in `
parse'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builtin/box_add.rb:465:in `metadata_url?'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builtin/box_add.rb:77:in `block in call'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builtin/box_add.rb:75:in `map'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builtin/box_add.rb:75:in `call'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/warden.rb:34:in `call'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/builder.rb:116:in `call'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/runner.rb:66:in `block in run'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/u
til/busy.rb:19:in `busy'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a
ction/runner.rb:66:in `run'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/comma
nds/box/command/add.rb:89:in `execute'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/comma
nds/box/command/root.rb:61:in `execute'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/c
li.rb:42:in `execute'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/e
nvironment.rb:301:in `cli'
from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/bin/vagrant:1
74:in `<main>'
添加了一些错误:
$ vagrant box add mybox C:/Udacity/trusty-server-cloudimg-i386-vagrant-disk1.ta
r
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'mybox' (v0) for provider:
box: Unpacking necessary files from: file://C:/Udacity/trusty-server-cloudim
g-i386-vagrant-disk1.tar
box:
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 /Udacity/trusty-server-cloudimg-i386-vagrant-disk1.tar
您可能需要像下面这样添加框。请参阅http://docs.vagrantup.com/v2/cli/box.html
vagrant box add yourbox file:///box-file-location/yourbox.box
vagrant init yourbox
vagrant up