Table of Contents

Vagrant - (Lifetime|Lifecyle) - Command

About

The principal command of Vagrant are defining the lifetime of the virtual machine.

Steps

Init

Init a project directory to be used with vagrant.

cd myVagrantProjectDirectory
vagrant init

It will create a .vagrant directory into the directory project myVagrantProjectDirectory

and add a box. Bv for Ubuntu 64.

vagrant add hashicorp/precise64

Up

vagrant up brings the box VM clone up in the provider (by default VirtualBox)

Vagrant runs the virtual machine by default without a UI to prove that it's running start an ssh session.

From this steps, you want to provision your Vm. See Vagrant - Provision (Code, Software Installation)

Reload

vagrant reload quickly restart the virtual machine, skipping the initial import step.

Tear down

With Vagrant, you suspend, halt, or destroy the guest machine. Each of these options have pros and cons.

Suspend

  1. vagrant suspend will save the current running state of the machine and stop it.
  2. vagrant up will resumed the machine from where you left off.

Cons and pro:

Halt

  1. vagrant halt will gracefully shut down the guest operating system and power down the guest machine.
  2. vagrant up to boot the machine again.

Pro and cons:

Destroy

  1. 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.
  2. vagrant up to restart

Pro and cons:

The vagrant destroy command does not actually remove the downloaded box file. To remove it, see vagrant box remove