How To Install Vagrant on Rocky Linux 8

In this guide, you will learn to Install Vagrant on Rocky Linux 8.

A vagrant is a tool for building and managing virtual machine environments in a single workflow. Vagrant provides a simple and easy-to-use command-line client for managing these environments, focuses on automation, and is an interpreter for the text-based definitions of what each environment looks like, called Vagrantfiles. Vagrant decreases development environment setup time and increases production parity.

Steps To Install Vagrant on Rocky Linux 8

To complete this guide, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article about the Initial Server Setup with Rocky Linux 8.

Also, you need to install VirtualBox on your server. For this, you can check our article How To Install VirtualBox on Rocky Linux 8.

Install Vagrant on Rocky Linux 8

To install vagrant, you need to install the yum-utils package on your server:

sudo dnf install -y yum-utils

Add Vagrant Repository

Then, use the command below to add the Vagrant repo on Rocky Linux 8:

sudo yum-config-manager --add-repo

Install Vagrant

Next, you can install the latest Vagrant with the following command:

sudo dnf -y install vagrant

Now you can verify your installation by checking the Vagrant version:

vagrant --version

In your output you will see:

Vagrant 2.3.4

You have successfully installed Vagrant on Rocky Linux 8, let’s see how to use it.

How To Use Vagrant

At this point, we want to show you how to use Vagrant by creating a development environment.

First, you need to create a file to save the Vagrant file there. To do this, run the following command:

mkdir ~/vagrant-project

Then, you need to initialize a new Vagrantfile and specify the box you wish to use on Rocky Linux 8.

Boxes are the package format for the Vagrant environments and are provider-specific.

You can check the list of available Vagrant Boxes on the Vagrant Catalog page.

In this example, we want to use ubuntu/trusty64.

Switch to your Vagrant project directory on Rocky Linux 8 with the following command:

cd ~/vagrant-project

Now initialize the Vagrantfile with the following command:

vagrant init ubuntu/trusty64

In your output you will see:

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`` for more information on using Vagrant.

You can open the Vagrantfile with your favorite text editor and make changes according to your needs on Rocky Linux 8.

Run the following command to create and configure the virtual machine as defined in the Vagrantfile:

vagrant up
==> default: Configuring and enabling network interfaces...

Vagrant mounts the project directory at /vagrant in the virtual machine. This allows you to work on the project’s files on your host machine.

You can use the following command to ssh to your virtual machine:

vagrant ssh

Also, you can stop the virtual machine with the command below:

vagrant halt

If you want to stop and destroy all resources that were created during the creation of the machine, you can use the following command:

vagrant destroy


At this point, you have learned to Install and Use Vagrant on Rocky Linux 8.

Hope you enjoy using it. Please subscribe to us on Facebook and Twitter.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!