LinuxCommandLibrary

vagrant-destroy

Destroy Vagrant virtual machines

TLDR

Destroy the currently running machine

$ vagrant destroy
copy

Target a machine by name or ID
$ vagrant destroy [name|id]
copy

Do not ask for confirmation before destroying
$ vagrant destroy [[-f|--force]]
copy

Shut down the machine gracefully
$ vagrant destroy [[-g|--graceful]]
copy

SYNOPSIS

vagrant destroy [options] [name|id]

Common options:
--force, -f

PARAMETERS

--force, -f
    Skips the confirmation prompt, destroying the virtual machine(s) immediately. Use with extreme caution as this action is irreversible.

DESCRIPTION

The vagrant destroy command is used to destroy all resources created for a specific Vagrant environment, effectively deleting the associated virtual machine. This command is crucial for cleaning up development environments, freeing up disk space, and resetting a project's VM state. When executed, Vagrant will prompt for confirmation before proceeding, as this action is irreversible and will lead to permanent data loss on the virtual machine's disk. It removes the virtual machine from the provider (e.g., VirtualBox, VMware), deletes its associated disk images, and cleans up any network interfaces or shared folders created by Vagrant. It's a fundamental part of the Vagrant lifecycle, often used after a project is completed or when a fresh start is required. While the virtual machine itself is destroyed, the Vagrantfile and any project source code on the host machine remain untouched, allowing for a fresh vagrant up to recreate the environment easily.

CAVEATS

Using vagrant destroy is an irreversible action that results in permanent data loss for the virtual machine. Any unsaved work, configurations, or databases within the VM will be lost. It is not a backup mechanism. Ensure all necessary data is backed up or synchronized before running this command. It only destroys resources managed by Vagrant; external resources or host-side files remain untouched.

MULTI-VM ENVIRONMENTS

In a multi-VM Vagrantfile, you can specify a particular virtual machine to destroy by providing its name or ID as an argument (e.g., vagrant destroy web or vagrant destroy 1234567). If no name or ID is specified in a multi-VM environment, Vagrant will prompt to destroy all defined virtual machines within the project.

WHAT IS REMOVED / WHAT REMAINS

The vagrant destroy command removes the virtual machine instance from the chosen provider (e.g., VirtualBox, VMware, KVM) and deletes its associated virtual disk image files from your host system. It cleans up any Vagrant-specific network configurations or shared folder mounts. However, it does not delete the local Vagrantfile, the .vagrant directory (which contains Vagrant's state and data), or any source code directories on your host machine. This allows for easy recreation of the environment using a subsequent vagrant up command.

HISTORY

Vagrant, developed by Mitchell Hashimoto, emerged as a popular tool in the early 2010s to simplify the creation and management of reproducible development environments. The destroy command has been a core component of Vagrant's lifecycle management since its early versions, providing a straightforward way to clean up virtual machine resources. Its design reflects Vagrant's philosophy of making environment setup and teardown efficient and predictable, crucial for modern development workflows where environments are often ephemeral.

SEE ALSO

vagrant up, vagrant halt, vagrant suspend, vagrant status, vagrant provision

Copied to clipboard