Vagrant - (Lifetime|Lifecyle) - Command
The principal command of Vagrant are defining the lifetime of the virtual machine.
Init a project directory to be used with vagrant.
It will create a .vagrant directory into the directory project myVagrantProjectDirectory
and add a box. Bv for Ubuntu 64.
vagrant add hashicorp/precise64
Vagrant runs the virtual machine by default without a UI to prove that it's running start an ssh session.
vagrant reload quickly restart the virtual machine, skipping the initial import step.
With Vagrant, you suspend, halt, or destroy the guest machine. Each of these options have pros and cons.
- vagrant suspend will save the current running state of the machine and stop it.
- vagrant up will resumed the machine from where you left off.
Cons and pro:
- The main benefit of this method is that it is super fast, usually taking only 5 to 10 seconds to stop and start your work.
- The downside is that the virtual machine still eats up your disk space, and requires even more disk space to store all the state of the virtual machine RAM on disk.
- vagrant halt will gracefully shut down the guest operating system and power down the guest machine.
- vagrant up to boot the machine again.
Pro and cons:
- The benefit of this method is that it will cleanly shut down your machine, preserving the contents of disk, and allowing it to be cleanly started again.
- The downside is that it'll take some extra time to start from a cold boot, and the guest machine still consumes disk space.
- vagrant destroy will remove all traces of the guest machine from your system. It'll stop the guest machine, power it down, and remove all of the guest hard disks.
- vagrant up to restart
Pro and cons:
- The benefit of this is that no cruft is left on your machine. The disk space and RAM consumed by the guest machine is reclaimed and your host machine is left clean.
- The downside is that vagrant up to get working again will take some extra time since it has to reimport the machine and re-provision it.
The vagrant destroy command does not actually remove the downloaded box file. To remove it, see vagrant box remove