How to Create a Virtual Machine using Vagrant

creating virtual machines using vagrant

For creating a virtual machine using vagrant, first you have to know about two things. First is “what is virtual machine ?” and second is “what is vagrant ?”

Virtual Machine

Virtual machine itself tells that it is a kind of virtual program or a virtual application environment that helps you to run different operating systems in your current operating system. Another benefit is that, each individual virtual machine itself act as a dedicated hardware.


Vagrant helps to configure easily and convenient for development environments. It helps to easily separate or detach dependencies from other working tools. So there is no need of sacrificing one particular tool for the working of another tool. Because of this advantage, you will get a reliable situation to work with.

For creating a virtual machine using vagrant, you can use different tools. The most popular one is VirtualBox. So you have to install VirtualBox for your particular operating system.

Steps for creating Virtual Machine using Vagrant

1) Install the VirtualBox from the below link :

2) Install Vagrant From the below link:

3) Create a directory and cd into the directory using the following command.

mkdir centos && cd centos

4) Now you have to add centos box to your system. It can found in VagrantCloud. You will get the centos file name from the below link.

5) Copy the first file from the above website link and paste that after typing the command: vagrant box add. Then the command will be:

vagrant box add puphpet/centos65-x64

8) Then the centos vagrant box will be added. You will see the output as shown below.

==> box: Loading metadata for box 'puphpet/centos65-x64'
box: URL:
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) parallels
2) VirtualBox
3) vmware_desktop

Enter your choice:

9) Next enter your choice. That means using which provider you are going to proceed. Here you can choose 2, that means you are using VirtualBox instead of parallels and vmware_desktop.

Enter your choice: 2
==> box: Adding box 'puphpet/centos65-x64' (v20151130) for provider: virtualbox
The box you're attempting to add already exists. Remove it before
adding it again or add it with the `--force` flag.

Name: puphpet/centos65-x64
Provider: virtualbox
Version: 20151130

10) You can check your vagrant box list, whether your centos files are listed inside or not.
For that, type the following command:

vagrant box list

11) Create the Vagrantfile using the centos box name. The command for creating vagrant file is:

vagrant init puppet/centos65-x64

12) Now type the list command to check if Vagrantfile has been created.


13) Open the centos Vagrantfile from where you saved vagrant folder in your system. Then include the below contents only in that file using any text editor. If you don’t have one, you can use the sublime editor. The sublime editor can be downloaded from the below link.

Below are the contents that are necessary for creating a virtual machine. These are written in the ruby language and should be saved in the sublime editor.

vagrant.configure(2) do |config| = "puphpet/centos65-x64" "private_network", ip: ""

config.vm.provider "virtualbox" do |vb|

vb.memory = "1024"

14) Then type the command : vagrant up to start the working of a virtual machine using vagrant.

vagrant up

15) Then check the status of the vagrant by typing the command.

vagrant status

16) By following these steps, you already created the virtual machine using vagrant.

If you want to connect the running vagrant machine to the shell, use the following command.

vagrant ssh


The new economy needs a new approach to education. Education is no longer a one-time investment at the beginning of one's career, it's a lifelong pursuit. We're building an educational experience that empowers our readers to thrive in this new world order.

Leave Comment