How to install CentOS 7 on VirtualBox using Vagrant

In my last post, I covered some basic information about installing Vagrant and VirtualBox on Ubuntu 18.10. In this post, I would like to cover the procedure of how to install CentOS Linux 7 on VirtualBox using Vagrant.

To get started, We need a few things. Namely:

  • Vagrant 2.2.2
  • VirtualBox-5.2_5
  • Ubuntu Linux 18.10
  • GitHub account
  • git command line tool

You may think why we need to have a GitHub account. As I mentioned in the last post, vagrant allows converting a virtual machine as a portable format.  Hence, I would like to use a Github repository for storing a virtual configuration in the form of Vagrantfile.

To start with, Just make sure that you have created a GitHub account and login into Once you are successfully logged into GitHub account, you will see an Introduction dashboard home screen. On the dashboard screen, click on New repository.

Next, type your repository name, description and choose Public or Private option, and then click Create repository.

Upon successful creation of a repository, you will see the page below like this.

Now, vagrant-centos7 repository has created on However, we need to have git command line tool installed in the system to use the GitHub repository. Let’s install git command line tool in Ubuntu 18.10.

Once the installation is successful, run the command displayed below to verify the installation.

As part of this exercise, I wanted to create a Project folder under my home directory. Thus, I have created a project folder under ~/vagrant and used git clone command line tool to clone vagrant-centos7 repository.

The command displayed below shows that git clone is successfully completed and you will find all the files that were in the GitHub repository.

Now, Let’s run vagrant init command line tool to create Vagrantfile. Vagrantfile is a ruby file used to configure CPU, Memory, Network, OS and so on for VirtualBox creation.

The above output shows that Vagrantfile is successfully created. To confirm CentOS 7 vagrant box is included in Vagrantfile, run cat Vagrantfile command to verify.

if the displayed command above looks fine, run vagrant up command line tool to bring up CentOS 7 on VirtualBox.  In case, you see any warning, you can safely ignore that.

We have almost reached the end of the blog. Now, Let’s run vagrant ssh command to log in to CentOS 7. Cool!  We can see CentOS Linux 7.6 is up and running on Vagrant VirtualBox on Ubuntu 18.10.

Next, As I mentioned earlier, I want to store Vagrantfile in the GitHub repository to use this configuration in the future. To do this, we need to run a couple of git commands

Let’s run git status command line tool to check what were the changes added in vagrant-centos7 repository.

The above output shows that a couple of untracked files present in git status output. To add those files, type git add .  command and git commit command to commit the changes in the repository.

Now, type git push command to push the committed files to vagrant-centos7 GitHub repository.

Fantastic!  you can see that changes are updated in my GitHub repository.

Thanks for reading my blog. Do share the post if you like it.

2 thoughts on “How to install CentOS 7 on VirtualBox using Vagrant”

  1. Where to specify the RAM, Disk size, network adapter setting for the VM? Can it be done through the vagrant file?

Leave a Comment

Your email address will not be published. Required fields are marked *

four × 2 =