Quick Start to Vagrant on Windows 10

In this article, I will show you how to install and use Vagrant on Windows 10. First, we will install the required tools and then we will up and run an Ubuntu desktop vagrant box with vagrant commands.

Required Tools

  • Virtualbox
  • Vagrant
  • Git

What does Vagrant do?

– Create and destroy VMs

– Starts, stops, restarts VMs

– Access to VMs

– Networking and WM settings

– Orchestrates “provisioning” for on-demand setup

 Steps to Up and Run Ubuntu Desktop (GUI Mode) via Vagrant

 1- Install Git for Windows

Download URL: https://git-scm.com/download/win

Then during installation steps, select below settings:

  • Use Git from the Windows Command Prompt” with this option you will be able to use Git from both Git Bash and the Windows Command Prompt.
  • Checkout as-is, commit Unix-style line endings

And finish the installation.

2- Install VirtualBox

For the sake of compatibility and in order to eliminate the version problems please install VirtualBox 5.1.14r112924 (Qt5.6.2) version.

 Downlod Link: http://download.virtualbox.org/virtualbox/5.1.4/VirtualBox-5.1.4-110228-Win.exe

 Installation of VirtualBox is pretty straight-forward. Just click the .exe file and click next -> next -> next to finish installation.

Also, download Oracle VM VirtualBox Extension Pack.

 Download Link: http://download.virtualbox.org/virtualbox/5.1.4/Oracle_VM_VirtualBox_Extension_Pack-5.1.4.vbox-extpack

Then, open VirtualBox and click File -> Preferences -> Extensions click the below icon

And select the extension pack and then click “Install” -> “I Agree” -> “Yes

3- Install Vagrant

In order to eliminate compatibility issues, it is better to install Vagrant 1.9.2 version.

 Vagrant Download Link: https://releases.hashicorp.com/vagrant/1.9.2/vagrant_1.9.2.msi

Install the Vagrant it is very easy to install and then restart your machine.

 After these setting you should do below settings to run Vagrant without any problem:

1) Enable VT-X (Intel Virtualization Technology) in your computer bios settings.

2) Disable Hyper-V on program and features page in the control panel.

Download and Run Ubuntu Desktop (GUI) Vagrant Box on Windows 10

Open Git Bash and type “pwd” it should show your user directory as shown below:

/c/Users/onurb

Then, create a folder as “project” by using “mkdir projects” command.

Then, go to that folder with “cd projects

Then create a folder for Ubuntu by using “mkdir ubuntu1404-desktop” command.

and go to that folder with “cd ubuntu1404-desktop” command.

After these steps run below commands sequentially:

vagrant init box-cutter/ubuntu1404-desktop

vagrant up –provider virtualbox

Then, Vagrant download and then run the box.

Vagrant Box Link: https://atlas.hashicorp.com/box-cutter/boxes/ubuntu1404-desktop/versions/2.0.26

 After these settings whenever you will run “vagrant up” command, Vagrant will run and open the Ubuntu in GUI mode as shown below:

Also, you can use any ready Vagrant box from below page.

https://atlas.hashicorp.com/boxes/search

Most Common Vagrant Commands

I will also summarise Vagrant commands with images. This time I will use “hashicorp/precise64” Linux box.

vagrant init: (initialize)

vagrant up: download image and do rest of the settings and power-up the box

vagrant status: Shows status

vagrant suspend: Saves the box’s current state

vagrant halt: shutdown the box (Power-off)

vagrant destroy:  shutdown and delete the box

Vagrant init (Initialize)

Vagrant up (Run the VM)

Vagrant suspend (Save the VM’s State)

Vagrant halt (Shut down the VM)

Vagrant ssh (Connecting non-gui Linux OS)

Vagrant version (Get Version Information)

Version Control of Vagrant by Using Git

You can edit VagrantFile and commit the modifications in a git repo by using below commands.

git version: get version information

git init: initialize the repo

git add: adding files to git repo

git commit -m “comment”: committing a file with a comment

git log –oneline: showing log history one line

git status: showing status of modifications

git ignore: Ignores the file types and do not hold them in the repo.

Create a .gitignore file and add “.vagrant” in it.

Add and Commit it into repo:

QUIZ TIME :)

Question 1:

How do you start a virtual machine with Vagrant?

vagrant up

Question 2:

A vagrant box must exist on the local system before the vagrant up command can be called.

No

Question 3:

How does Vagrant allow for keeping files synchronised between the host and the guest?

shared folders

Question 4:

How do we stop our vagrant-managed virtual machine from running?

vagrant suspend (save the state)

vagrant halt (shutdown)

vagrant destroy (shutdown and delete)

Question 5:

The vagrant status command tells us the current state of the vagrant-managed virtual machine for our project.

true

In this article, we learnt how to install, use, up and run a Vagrant Box in windows 10. I hope this helps you in your test environment needs.

Thanks.

-Onur

9 thoughts on “Quick Start to Vagrant on Windows 10”

  1. Hi am getting the following error please give some suggestion to solve it, thanks in advance

    The box ‘box-cluster/ubuntu1404-desktop’ could not be found or
    could not be accessed in the remote catalog. If this is a private
    box on HashiCorp’s Vagrant Cloud, please verify you’re logged in via
    `vagrant login`. Also, please double-check the name. The expanded
    URL and error message are shown below:

    URL: [“https://vagrantcloud.com/box-cluster/ubuntu1404-desktop”]
    Error: Failed to connect to vagrantcloud.com port 443: Timed out

    Reply
  2. Hi All,
    If you are getting the following error,
    You have to do some sonfiguration change in the Vagrantfile.
    *****Problem
    ==> default: Box ‘box-cutter/ubuntu1404-desktop’ could not be found. Attempting to find and install…
    default: Box Provider: virtualbox
    default: Box Version: >= 0
    ==> default: Loading metadata for box ‘box-cutter/ubuntu1404-desktop’
    default: URL: https://vagrantcloud.com/box-cutter/ubuntu1404-desktop
    ==> default: Adding box ‘box-cutter/ubuntu1404-desktop’ (v2.0.26) for provider: virtualbox

    ***Solution
    Under Vagrentfile, define the download location of the box file as follows.

    # Every Vagrant development environment requires a box. You can search for
    # boxes at https://vagrantcloud.com/search.

    config.vm.box_url = “https://app.vagrantup.com/hashicorp/boxes/precise64”
    config.vm.box = “hashicorp/precise64”

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.