Vagrant
Teardown an environment
Now that you've explored your development environment, it's time to stop, shut down, and finally destroy the environment. When using Vagrant you will choose from these options depending on how long you are stopping your work for, and whether or not you want to be able to come back to it.
Suspend the machine
Suspending the virtual machine will stop it and save its current running state. Suspend the machine now.
$ vagrant suspend
==> default: Saving VM state and suspending execution...
When you begin working again bring the machine back up and its state resumes from where you left off. Start the machine again.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/bionic64' version '1.0.282' is up to date...
==> default: Resuming suspended VM...
##... output truncated ...
Suspending your machine is intended for stopping and starting work quickly. The downside is that the virtual machine will still use disk space while suspended, and requires additional disk space to store the state of the virtual machine RAM.
Halt the machine
Halting the virtual machine will gracefully shut down the guest operating system and power down the guest machine. Halt your machine now.
$ vagrant halt
==> default: Attempting graceful shutdown of VM...
Halting your machine will cleanly shut it down, preserving the contents of disk and allowing you to cleanly start it again. Restart your machine.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/bionic64' version '1.0.282' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
##... output truncated ...
A halted guest machine will take more time to start from a cold boot and will still consume disk space.
Destroy the machine
Destroying the virtual machine will remove
all traces of the guest machine from your system. It'll stop the guest machine,
power it down, and reclaim its disk space and RAM. Destroy the machine now, and confirm with a yes
when prompted.
$ vagrant destroy
default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
Again, when you are ready to
work again, just issue a vagrant up
.
It takes even longer to bring a machine up once you destroy it, and the machine's state will not be saved.
You have successfully suspended, halted, and destroyed your virtual environment with Vagrant.