top of page

Vagrant Crash Course- Development Environments Made Easy

Vagrant is an open-source software product for building and maintaining portable virtual software development environments; e.g., for VirtualBox, KVM, Hyper-V, Docker containers, VMware, and AWS. It tries to simplify the software configuration management of virtualization in order to increase development productivity.

Vagrant Setup

  1. VT(Virtualization Technology) Enabled in Bios.

  2. Setup Oracle VM VirtualBox.

  3. Vagrant Tool

  4. CLI like Git Bash, CMD prompt...

Note: You can use Chocolatey for auto-deployment

VM Setup with vagrant

  1. Create a project directory at any location.

  2. Navigate to "" and choose the relevant box.

  3. Create Vagrantfile in Project Directory.

  4. Create a virtual box using the "Vagrant up" command.

Step-By-Step guide

in the following example, I will create a new Centos7 Virtual box using the vagrant file.

Step 1: Creating a project directory

The project directory for this example is "C:\Vagrant-Training\CentosExample"

Step 2: Open CLI to run Vegrant commands

Open Git Bash and navigate to the project directory:

Step 3: Locating the Vagrant file

Navigate to "" and query for "Centos", select package, and copy command:

Step 4: Creating the Vagrant file in project folder

Step 5: Create a new VM

To create a new VM, we will use the "Vagrant up" command


Step 6: Connect to VM using Vagrant command

To access the VM we will use the "Vagrant ssh" Command (It must run from the same directory!)

Additional commands:

Power OFF VM - vagrant halt

Power On (If VM is already created) - vagrant up

Delete VM - vagrant destroy

Power ON VM - vagrant halt

Reboot VM - vagrant reload

How do you get a list of all the VMs in the repository?

On Git Bash command line run the following command:

vagrant global-status
$ vagrant global-status
id       name    provider   state    directory
587056c  default virtualbox poweroff C:/vagrant-vms/ubunto
7f7943a  default virtualbox running  C:/vagrant-vms
f462fac  default virtualbox running  C:/vagrant-vms/centos7
bebdf84  default virtualbox running  C:/vagrant-training/centosExample

The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date (use "vagrant global-status --prune" to prune invalid
entries). To interact with any of the machines, you can go to that
directory and run Vagrant, or you can use the ID directly with
Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"

let's update the list using the "prune" attribute:

$ vagrant global-status --prune
id       name    provider   state   directory
bebdf84  default virtualbox running C:/vagrant-training/centosExample

How do you get a status of a specific VM?

To get the status on a specific VM, go to its directory and type "Vagrant Status":

David@DESKTOP-VIK2BBH MINGW64 /c/vagrant-vms/ubunto
$ vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

How can we customize the VM specification by changing the vagrant file?

By editing the Vagrant file in a specific VM directory, we can customize the VM specification.

Note: Ls -a will also d