如何本地添加 vagrant box?
用DOS下载太慢了,听说可以复制链接直接下载,但是如何添加呢?
用DOS下载太慢了,听说可以复制链接直接下载,但是如何添加呢?
2015-01-13
勤看文档啊,文档里啥都有:
通过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接受一个<name, url, or path>的参数,说明这个文件的路径可以是一个url或者是一个本地路径,而vagrant的box是可以被重命名的,比如同一个镜像文件文件,可以在在vagrant的box里叫不同的名字,这个名字在你的vagrantfile里是需要定义的,这样vagrant才能够通过box的名字找到具体的镜像文件。
所以最终添加本地命令的格式为:
vagrant box add --name box_name /path/of/box/file
举报