3.1-Box

Box

命令: vagrant box

这是用于管理(添加,删除等)box的命令。

该命令的主要功能通过更多的子命令实现:

  • add
  • list
  • outdated
  • prune
  • remove
  • repackage
  • update

Box Add

命令:vagrant box add ADDRESS

通过一个给定地址在Vagrant中增加box。地址可以是以下三类:

  • [可用的Vagrant镜像的公共目录](https://vagrantcloud.com/boxes/search)中的简写名称,如“hashicorp / precise64”。

  • box的文件路径或HTTP URL[目录](https://vagrantcloud.com/boxes/search)。对于HTTP,支持基本身份验证并且遵守http_proxy环境变量。 同时支持HTTPS。

  • 网址直接指向一个box文件。在这种情况下,您必须指定--name标志(请参见下文),版本控制/更新将不起作用。

如果在下载过程中发生错误,或者下载被Ctrl-C中断,则Vagrant将在下次请求时尝试恢复下载。Vagrant只会尝试在首次下载后24内恢复下载。

»选项

  • [--box-version VALUE](https://www.vagrantup.com/docs/cli/box.html#box-version-value) - 您要添加的box的版本。默认情况下,将添加最新版本。它的值可以是一个确切的版本号,例如“1.2.3”,或者它可以是一组版本约束。版本约束看起来像 “> = 1.0,<2.0”。

  • [--cacert CERTFILE](https://www.vagrantup.com/docs/cli/box.html#cacert-certfile) - 用于验证对等方的CA证书。如果远程端不使用标准的根CA,则应该使用此选项。

  • [--capath CERTDIR](https://www.vagrantup.com/docs/cli/box.html#capath-certdir) - 用于验证对等方的CA的证书目录。如果远程端不使用标准的根CA,则应该使用此选项。

  • [--cert CERTFILE](https://www.vagrantup.com/docs/cli/box.html#cert-certfile) - 必要时,下载盒子时使用的客户端证书。

  • [--clean](https://www.vagrantup.com/docs/cli/box.html#clean) - 如果提供,Vagrant将删除之前下载相同URL的所有旧临时文件。在您不希望Vagrant从前一点继续下载时使用,这可能是因为内容已经改变了。

  • [--force](https://www.vagrantup.com/docs/cli/box.html#force) - 当出现时,该box将被下载并用此名称覆盖任何现有的box。

  • [--insecure](https://www.vagrantup.com/docs/cli/box.html#insecure) - 当出现时,如果该URL是HTTPS URL,SSL证书将不会被验证。

  • [--provider PROVIDER](https://www.vagrantup.com/docs/cli/box.html#provider-provider) - 如果有的话,Vagrant将验证您添加的box是给定的提供商。默认情况下,Vagrant会自动检测到使用的适当的提供商。

[»](https://www.vagrantup.com/docs/cli/box.html#options-for-direct-box-files)直接box文件的选项

下面的选项仅适用于直接添加box文件(当您不使用目录时)。

  • [--checksum VALUE](https://www.vagrantup.com/docs/cli/box.html#checksum-value) - 下载的框的校验和。如果指定,Vagrant会将此校验和与实际下载的校验和进行比较,如果校验和不匹配,则会出错。这是强烈建议,因为箱子文件是如此之大。如果指定了,则还必须指定--checksum-type。如果您从目录下载,则校验和将包含在目录条目中。

  • [--checksum-type TYPE](https://www.vagrantup.com/docs/cli/box.html#checksum-type-type) - “--checksum”的校验和类型如果它被指定。支持的值目前是“md5”,“sha1”和“sha256”。

  • [--name VALUE](https://www.vagrantup.com/docs/cli/box.html#name-value) - 该框的逻辑名称。这是你在Vagrantfile中放入config.vm.box的值。从目录添加箱子时,该名称包含在目录条目中,无需指定。

** HashCorp的Vagrant Cloud版本化框或框的校验和:**对于来自HashiCorp的Vagrant Cloud的框,校验和被嵌入到框的元数据中。元数据本身通过TLS提供,其格式经过验证。

»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.

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.

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.

你可能感兴趣的:(3.1-Box)