Box
命令: vagrant box
這是用于管理(添加,刪除等)box的命令。
該命令的主要功能通過更多的子命令實(shí)現(xiàn):
Box Add
命令:vagrant box add ADDRESS
通過一個(gè)給定地址在Vagrant中增加box。地址可以是以下三類:
[可用的Vagrant鏡像的公共目錄](https://vagrantcloud.com/boxes/search)中的簡寫名稱,如“hashicorp / precise64”。
box的文件路徑或HTTP URL[目錄](https://vagrantcloud.com/boxes/search)。對(duì)于HTTP,支持基本身份驗(yàn)證并且遵守
http_proxy環(huán)境變量。 同時(shí)支持HTTPS。網(wǎng)址直接指向一個(gè)box文件。在這種情況下,您必須指定--name標(biāo)志(請(qǐng)參見下文),版本控制/更新將不起作用。
如果在下載過程中發(fā)生錯(cuò)誤,或者下載被Ctrl-C中斷,則Vagrant將在下次請(qǐng)求時(shí)嘗試恢復(fù)下載。Vagrant只會(huì)嘗試在首次下載后24內(nèi)恢復(fù)下載。
?選項(xiàng)
[
--box-version VALUE](https://www.vagrantup.com/docs/cli/box.html#box-version-value) - 您要添加的box的版本。默認(rèn)情況下,將添加最新版本。它的值可以是一個(gè)確切的版本號(hào),例如“1.2.3”,或者它可以是一組版本約束。版本約束看起來像 “> = 1.0,<2.0”。[
--cacert CERTFILE](https://www.vagrantup.com/docs/cli/box.html#cacert-certfile) - 用于驗(yàn)證對(duì)等方的CA證書。如果遠(yuǎn)程端不使用標(biāo)準(zhǔn)的根CA,則應(yīng)該使用此選項(xiàng)。[
--capath CERTDIR](https://www.vagrantup.com/docs/cli/box.html#capath-certdir) - 用于驗(yàn)證對(duì)等方的CA的證書目錄。如果遠(yuǎn)程端不使用標(biāo)準(zhǔn)的根CA,則應(yīng)該使用此選項(xiàng)。[
--cert CERTFILE](https://www.vagrantup.com/docs/cli/box.html#cert-certfile) - 必要時(shí),下載盒子時(shí)使用的客戶端證書。[
--clean](https://www.vagrantup.com/docs/cli/box.html#clean) - 如果提供,Vagrant將刪除之前下載相同URL的所有舊臨時(shí)文件。在您不希望Vagrant從前一點(diǎn)繼續(xù)下載時(shí)使用,這可能是因?yàn)閮?nèi)容已經(jīng)改變了。[
--force](https://www.vagrantup.com/docs/cli/box.html#force) - 當(dāng)出現(xiàn)時(shí),該box將被下載并用此名稱覆蓋任何現(xiàn)有的box。[
--insecure](https://www.vagrantup.com/docs/cli/box.html#insecure) - 當(dāng)出現(xiàn)時(shí),如果該URL是HTTPS URL,SSL證書將不會(huì)被驗(yàn)證。[
--provider PROVIDER](https://www.vagrantup.com/docs/cli/box.html#provider-provider) - 如果有的話,Vagrant將驗(yàn)證您添加的box是給定的提供商。默認(rèn)情況下,Vagrant會(huì)自動(dòng)檢測到使用的適當(dāng)?shù)奶峁┥獭?/p>
[?](https://www.vagrantup.com/docs/cli/box.html#options-for-direct-box-files)直接box文件的選項(xiàng)
下面的選項(xiàng)僅適用于直接添加box文件(當(dāng)您不使用目錄時(shí))。
[
--checksum VALUE](https://www.vagrantup.com/docs/cli/box.html#checksum-value) - 下載的框的校驗(yàn)和。如果指定,Vagrant會(huì)將此校驗(yàn)和與實(shí)際下載的校驗(yàn)和進(jìn)行比較,如果校驗(yàn)和不匹配,則會(huì)出錯(cuò)。這是強(qiáng)烈建議,因?yàn)橄渥游募侨绱酥?。如果指定了,則還必須指定--checksum-type。如果您從目錄下載,則校驗(yàn)和將包含在目錄條目中。[
--checksum-type TYPE](https://www.vagrantup.com/docs/cli/box.html#checksum-type-type) - “--checksum”的校驗(yàn)和類型如果它被指定。支持的值目前是“md5”,“sha1”和“sha256”。[
--name VALUE](https://www.vagrantup.com/docs/cli/box.html#name-value) - 該框的邏輯名稱。這是你在Vagrantfile中放入config.vm.box的值。從目錄添加箱子時(shí),該名稱包含在目錄條目中,無需指定。
** HashCorp的Vagrant Cloud版本化框或框的校驗(yàn)和:**對(duì)于來自HashiCorp的Vagrant Cloud的框,校驗(yàn)和被嵌入到框的元數(shù)據(jù)中。元數(shù)據(jù)本身通過TLS提供,其格式經(jīng)過驗(yàn)證。
?Options for direct box files
The options below only apply if you are adding a box file directly (when you are not using a catalog).
--checksum VALUE- A checksum for the box that is downloaded. If specified, Vagrant will compare this checksum to what is actually downloaded and will error if the checksums do not match. This is highly recommended since box files are so large. If this is specified,--checksum-typemust also be specified. If you are downloading from a catalog, the checksum is included within the catalog entry.--checksum-type TYPE- The type of checksum that--checksumis if it is specified. Supported values are currently "md5", "sha1", and "sha256".--name VALUE- Logical name for the box. This is the value that you would put intoconfig.vm.boxin your Vagrantfile. When adding a box from a catalog, the name is included in the catalog entry and does not have to be specified.
Checksums for versioned boxes or boxes from HashiCorp's Vagrant Cloud: For boxes from HashiCorp's Vagrant Cloud, the checksums are embedded in the metadata of the box. The metadata itself is served over TLS and its format is validated.
Box List
Command: vagrant box list
This command lists all the boxes that are installed into Vagrant.
Box Outdated
Command: vagrant box outdated
This command tells you whether or not the box you are using in your current Vagrant environment is outdated. If the --global flag is present, every installed box will be checked for updates.
Checking for updates involves refreshing the metadata associated with a box. This generally requires an internet connection.
?Options
-
--global- Check for updates for all installed boxes, not just the boxes for the current Vagrant environment.
Box Prune
Command: vagrant box prune
This command removes old versions of installed boxes. If the box is currently in use vagrant will ask for confirmation.
?Options
--provider PROVIDER- The specific provider type for the boxes to destroy.--dry-run- Only print the boxes that would be removed.--name NAME- The specific box name to check for outdated versions.--force- Destroy without confirmation even when box is in use.
Box Remove
Command: vagrant box remove NAME
This command removes a box from Vagrant that matches the given name.
If a box has multiple providers, the exact provider must be specified with the --provider flag. If a box has multiple versions, you can select what versions to delete with the --box-version flag or remove all versions with the --all flag.
?Options
--box-version VALUE- Version of version constraints of the boxes to remove. See documentation on this flag forbox addfor more details.--all- Remove all available versions of a box.--force- Forces removing the box even if an active Vagrant environment is using it.--provider VALUE- The provider-specific box to remove with the given name. This is only required if a box is backed by multiple providers. If there is only a single provider, Vagrant will default to removing it.
Box Repackage
Command: vagrant box repackage NAME PROVIDER VERSION
This command repackages the given box and puts it in the current directory so you can redistribute it. The name, provider, and version of the box can be retrieved using vagrant box list.
When you add a box, Vagrant unpacks it and stores it internally. The original *.box file is not preserved. This command is useful for reclaiming a *.box file from an installed Vagrant box.
Box Update
Command: vagrant box update
This command updates the box for the current Vagrant environment if there are updates available. The command can also update a specific box (outside of an active Vagrant environment), by specifying the --box flag.
<small style="box-sizing: border-box; font-size: 12.75px;">Note that updating the box will not update an already-running Vagrant machine. To reflect the changes in the box, you will have to destroy and bring back up the Vagrant machine.</small>
If you just want to check if there are updates available, use the vagrant box outdated command.
?Options
--box VALUE- Name of a specific box to update. If this flag is not specified, Vagrant will update the boxes for the active Vagrant environment.--provider VALUE- When--boxis present, this controls what provider-specific box to update. This is not required unless the box has multiple providers. Without the--boxflag, this has no effect.