vagrant-box
Manage Vagrant boxes
TLDR
List all installed boxes
Add a new box
Add a box from a custom URL
Remove an installed box
Update all boxes that are in use in the current Vagrant environment
Update a specific box
Check if there is a new version available for the box that you are using
Clean up old versions of installed boxes
SYNOPSIS
vagrant box <command> [<args>]
Where <command> is one of the available box management operations, such as `add`, `list`, `remove`, `update`, or `prune`. The specific arguments `[<args>]` depend on the chosen command.
PARAMETERS
add <name> <url_or_path>
Adds a box to Vagrant.
Common options include:
--clean: Clean existing temporary downloads.
--checksum <value>: Checksum of the box.
--checksum-type <type>: Type of checksum (e.g., `sha1`, `md5`).
--force: Overwrite existing box if it already exists.
--insecure: Do not verify SSL certificates.
--provider <name>: The provider the box is for (e.g., `virtualbox`, `vmware`).
--box-version <version>: The version of the box being added.
list
Lists all installed boxes.
Common options include:
--machine-readable: Output in machine-readable format.
--json: Output in JSON format (newer versions).
remove <name>
Removes a box from Vagrant.
Common options include:
--all: Remove all versions of the box.
--box-version <version>: The specific version to remove.
--force: Remove even if used by a Vagrant environment.
update <name>
Updates an installed box to the latest version.
Common options include:
--box-version <version>: Update to a specific version.
--provider <name>: Update for a specific provider.
--clean: Clean existing temporary downloads.
prune
Removes old, unused box versions.
Common options include:
--dry-run: Don't actually remove, just show what would be removed.
--force: Prune even if boxes are in use.
DESCRIPTION
The `vagrant box` command is a fundamental subcommand within the Vagrant ecosystem, primarily used for managing boxes. A box in Vagrant is a packaged, pre-configured base virtual machine image. These images serve as the starting point for Vagrant environments, allowing users to quickly set up consistent development environments without needing to configure a VM from scratch. The `vagrant box` command provides functionalities to add new boxes from local files or remote URLs, list available boxes, remove unwanted boxes to free up disk space, and update existing boxes to newer versions. It's crucial for maintaining a collection of reusable VM images, enabling rapid environment provisioning and sharing within development teams.
CAVEATS
Boxes can consume significant disk space, especially if multiple versions or providers are kept. Regularly using `vagrant box prune` or `vagrant box remove` is recommended for disk management.
Ensure the box downloaded is compatible with your installed Vagrant provider (e.g., VirtualBox, VMware, Hyper-V).
Always use trusted sources for downloading boxes to avoid security risks.
Be mindful of box versions; different versions might have different guest additions or configurations.
BOX FORMAT
Vagrant boxes are essentially compressed archives (often `.box` files) containing the virtual machine image (e.g., VMDK, VHD, OVA), a `metadata.json` file specifying the provider, and potentially Vagrantfiles for default configurations.
DEFAULT BOX STORAGE LOCATION
By default, Vagrant stores downloaded boxes in `~/.vagrant.d/boxes/` on Linux/macOS and `%USERPROFILE%\.vagrant.d\boxes\` on Windows. Knowing this location can be useful for manual inspection or cleanup.
HISTORY
Vagrant, developed by Mitchell Hashimoto, was first released in 2010. The concept of "boxes" was central from its early days, designed to solve the "works on my machine" problem by providing reproducible development environments. The `vagrant box` command has been a core part of its functionality, evolving with features like checksumming, versioning, and provider-specific boxes to support a wider array of virtualization platforms and ensure greater reliability in box distribution and management.
SEE ALSO
vagrant init(1), vagrant up(1), vagrant destroy(1), vagrant global-status(1), virtualbox(1)