[Introduction] Build a virtual environment of Vagrant + VirtualBox on Window10 [Environment construction]

2 minute read

For the first time, I built a Vagrant environment with Window 10.
Build CentOS 7 using Vagrant and VirtualBox by referring to various introductory articles.

It was my first experience, so it was hard because I got a lot of unexpected errors …

I hope it will be useful so that later students can easily build the environment.

environment

Window10
Vagrant2.2.10
VirtualBox5.2.44

Vagrant practice file creation procedure

Disable Hyper-V

Window10 users who have used ** Docker ** should first turn off Hyper-V.

Please be sure to turn it off! !! !! !! !!

bcdedit /set hypervisorlaunchtype off
You have successfully completed this operation.

VirtualBox installation

I installed the latest version of 5 series. Get the installer from here and run it.

vagrant installation

I downloaded the latest version 2.2.10 at the time of writing. Basically, let’s install the latest version (64bit). Get the installer from here and run it.
After installation, you need to restart the OS.

After rebooting, start the command prompt and check the version.

vagrant -v
Vagrant 2.2.7

Install the plugin at the command prompt.
Introduce an omnibus plugin that installs Chef as needed and a VirtualboxGuestAddition tool for host-guest shared folder configuration. (If not, an error will occur)
Also install vagrant-hostmanager for replication.

vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-hostmanager

If you want to uninstall

vagrant plugin uninstall vagrant-omnibus
vagrant plugin uninstall vagrant-vbguest
vagrant plugin uninstall vagrant-hostmanager

View installed pluigin

vagrant plugin list

Addition of CentOS7 box

vagrant is managed using an image file and a configuration file called a box. Download the CentOS 7.7 box from vagrantcloud.com and add it for virtualbox.

This can be done at ** _ Command Prompt _ **.

_ It’s anxious because the processing time is long, so it’s already a break. _

> vagrant box add bento/centos-7.7 --provider virtualbox
==> box: Loading metadata for box 'bento/centos-7.7'
    box: URL: https://vagrantcloud.com/bento/centos-7.7
==> box: Adding box 'bento/centos-7.7' (v202002.04.0) for provider: virtualbox
    box: Downloading: https://vagrantcloud.com/bento/boxes/centos-7.7/versions/202002.04.0/providers/virtualbox.box
    box: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
    box: Progress: 100% (Rate: 457k/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'bento/centos-7.7' (v202002.04.0) for 'virtualbox'!

Create and initialize vagrant management folder

Initialize the project by creating a file in the location where you want to manage vagrant.

vagrant init bento/centos-7.7

A Vagrantfile of about 10MB is created.
Log files and management information are saved when the virtual machine starts.

Start virtual machine

Start the virtual machine with the vagrant up command.

vagrant up

Connect to virtual machine

vagrant ssh

You can now connect to the virtual machine you created for practice! !!

When you want to use Docker again

Set back to Auto

bcdedit /set hypervisorlaunchtype auto

And reboot

Created on 2020/10/14
Updated on 2020/10/23

References

  1. vagrant + VirtualBox + CentOS 7.7 environment construction (Windows 10)
  2. When I try to start Vagrant on Windows, it says Raw-mode is unavailable courtesy of Hyper-V
  3. VirtualBox cannot be used in Window10.