3.1-Box

Box

命令: vagrant box

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

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

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内恢复下载。

»选项

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

下面的选项仅适用于直接添加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.

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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,162评论 0 10
  • 今晚流氓兔推荐的歌曲是《甘心替代你》,郑伊健。特别喜欢前面部分唱的,好好听。又好深情。 三天过去了,我归来啦。发生...
    佐恬阅读 1,358评论 0 0
  • 没有想过自己的第一篇居然是为了工作,用“居然”这个词对我来说一点也不意外。一直以来工作于我只是生活的一部分其...
    小家女雄阅读 3,511评论 0 1
  • 『亮剑』里有个场景:李云龙带着一营趴在土堆上,看到日本兵的大阵仗,直觉告诉他再等一等,会等到大鱼。于是他从一个天亮...
    呼葱唤土豆阅读 1,820评论 2 2
  • 文/山雨林夕 一寸光阴一寸金,寸金难买寸光阴。 在宝爸宝妈们的世界里,时间是最珍贵的存在。 每天都恨不得有三个自己...
    山雨林夕阅读 3,218评论 0 0