vagrant up下载box慢的解决办法

即在运行vagrant up时得到其的下载路径,如:

https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20190101.0.0/providers/virtualbox.box

然后直接在浏览器*问该网址来下载该box

先查看本地安装的box:

userdeMBP:ubuntu-16.04 user$ vagrant box list
hashicorp/precise64 (virtualbox, 1.1.)
hashicorp/vagrant-share (virtualbox, 0.1.)
tknerr/baseimage-ubuntu-12.04 (docker, 1.0.)

再将得到的box文件手动添加进去:

userdeMBP:ubuntu-16.04 user$ vagrant box add --name ubuntu/xenial64 /Users/user/ubuntu-16.04/xenial-server-cloudimg-amd64-vagrant.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu/xenial64' (v0) for provider:
box: Unpacking necessary files from: file:///Users/user/ubuntu-16.04/xenial-server-cloudimg-amd64-vagrant.box
==> box: Successfully added box 'ubuntu/xenial64' (v0) for 'virtualbox'!

然后再查看本地果然多了一个新的box:

userdeMBP:ubuntu-16.04 user$ vagrant box list
hashicorp/precise64 (virtualbox, 1.1.)
hashicorp/vagrant-share (virtualbox, 0.1.)
tknerr/baseimage-ubuntu-12.04 (docker, 1.0.)
ubuntu/xenial64 (virtualbox, )

然后再在相应vagrantfile对应的目录下运行vagrant up即可运行起来了:

userdeMBP:ubuntu-16.04 user$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: ubuntu-1604_default_1546496409973_90048
==> default: Vagrant has detected a configuration issue which exposes a
==> default: vulnerability with the installed version of VirtualBox. The
==> default: current guest is configured to use an E1000 NIC type for a
==> default: network adapter which is vulnerable in this version of VirtualBox.
==> default: Ensure the guest is trusted to use this configuration or update
==> default: the NIC type using one of the methods below:
==> default:
==> default: https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type
==> default: https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter : nat
==> default: Forwarding ports...
default: (guest) => (host) (adapter )
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection reset. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 5.1.
default: VirtualBox Version: 5.2
==> default: Mounting shared folders...
default: /vagrant => /Users/user/ubuntu-16.04

然后使用vagrant ssh即可进入:

userdeMBP:ubuntu-16.04 user$ vagrant ssh
Welcome to Ubuntu 16.04. LTS (GNU/Linux 4.4.--generic x86_64) * Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud packages can be updated.
updates are security updates. New release '18.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it. vagrant@ubuntu-xenial:~$
上一篇:Redis的安装


下一篇:UI控件(UIToolbar)