3.1-Box

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)

[?](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-type must 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 --checksum is 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 into config.vm.box in 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 for box add for 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 --box is present, this controls what provider-specific box to update. This is not required unless the box has multiple providers. Without the --box flag, this has no effect.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,860評(píng)論 0 10
  • 今晚流氓兔推薦的歌曲是《甘心替代你》,鄭伊健。特別喜歡前面部分唱的,好好聽。又好深情。 三天過去了,我歸來啦。發(fā)生...
    佐恬閱讀 213評(píng)論 0 0
  • 沒有想過自己的第一篇居然是為了工作,用“居然”這個(gè)詞對(duì)我來說一點(diǎn)也不意外。一直以來工作于我只是生活的一部分其...
    小家女雄閱讀 569評(píng)論 0 1
  • 『亮劍』里有個(gè)場景:李云龍帶著一營趴在土堆上,看到日本兵的大陣仗,直覺告訴他再等一等,會(huì)等到大魚。于是他從一個(gè)天亮...
    呼蔥喚土豆閱讀 309評(píng)論 2 2
  • 文/山雨林夕 一寸光陰一寸金,寸金難買寸光陰。 在寶爸寶媽們的世界里,時(shí)間是最珍貴的存在。 每天都恨不得有三個(gè)自己...
    山雨林夕閱讀 510評(píng)論 0 0

友情鏈接更多精彩內(nèi)容