使用vagrant在线下载BOX 太慢,所以我们先用迅雷等工具下载到本地,使用本地添加的方法,我们结合vagrant 的帮助文档来学习一下。
通过vagrant --help我们知道了vagrant下面所有的命令:
$ vagrant --help
Usage: vagrant [options] <command> [<args>]
-v, --version Print the version and exit.
-h, --help Print this help.
Common commands:
box manages boxes: installation, removal, etc.
connect connect to a remotely shared Vagrant environment
destroy stops and deletes all traces of the vagrant machine
global-status outputs status Vagrant environments for this user
halt stops the vagrant machine
help shows the help for a subcommand
hostmanager
init initializes a new Vagrant environment by creating a Vagrantfile
login log in to Vagrant Cloud
package packages a running vagrant environment into a box
plugin manages plugins: install, uninstall, update, etc.
provision provisions the vagrant machine
rdp connects to machine via RDP
reload restarts vagrant machine, loads new Vagrantfile configuration
resume resume a suspended vagrant machine
share share your Vagrant environment with anyone in the world
ssh connects to machine via SSH
ssh-config outputs OpenSSH valid configuration to connect to the machine
status outputs status of the vagrant machine
suspend suspends the machine
up starts and provisions the vagrant environment
vbguest
version prints current and latest Vagrant version
For help on any individual command run `vagrant COMMAND -h`
Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.
可以看到如果要管理box的话,有一个box命令,那么我们继续看box下有什么子参数:
$ vagrant box --help
Usage: vagrant box <subcommand> [<args>]
Available subcommands:
add
list
outdated
remove
repackage
update
For help on any individual subcommand run `vagrant box <subcommand> -h`
可以看到有add参数,显然就是用来添加box的,那我们继续看看box add怎么用:
$ vagrant box add --help
Usage: vagrant box add [options] <name, url, or path>
Options:
-c, --clean Clean any temporary download files
-f, --force Overwrite an existing box if it exists
--insecure Do not validate SSL certificates
--cacert FILE CA certificate for SSL download
--capath DIR CA certificate directory for SSL download
--cert FILE A client SSL cert, if needed
--provider PROVIDER Provider the box should satisfy
--box-version VERSION Constrain version of the added box
The box descriptor can be the name of a box on Vagrant Cloud,
or a URL, or a local .box file, or a local .json file containing
the catalog metadata.
The options below only apply if you're adding a box file directly,
and not using a Vagrant server or a box structured like 'user/box':
--checksum CHECKSUM Checksum for the box
--checksum-type TYPE Checksum type (md5, sha1, sha256)
--name BOX Name of the box
-h, --help Print this help
可以看到box add接受一个
所以最终添加本地命令的格式为:
vagrant box add --name box_name /path/of/box/file
比如你先把centos7.box下载后存放到D:\vagrant\box\
,可以使用以下命令:
vagrant box add centos7.0 D:\vagrant\box\centos7.box
centos7.0是我们为自定义的box名字,后面会用到,最后接的是box文件路径
注:建议本地添加时候工作目录与box文件在同一磁盘下,比如C盘,D盘