Getting Started with Vagrant on Windows 10

To get started, go ahead and install these tools:

Note:
I have had so much trouble using the Vagrant 1.8.x, so the stable version Vagrant 1.7.4 and the corresponding VirtualBox version 5.0.24 are highly recommended.

Create Your Projects

Now that you have it all set up, you can start your first Vagrant project by creating a project folder, which will house the various configurations for each of your VMs. You'll use the command line to run Vagrant commands from within these folders.

Create your first project folder and call it C:\vm\Aquarius\ .

Note:
As a Windows user, you can quickly open a command prompt to your project by holding down shift and right-clicking the project folder, then choose "Open MobaXterm terminal here".

By default, MobaXterm does not preserve Windows "PATH" environment variable: this is why you obtain "command not found" when running "javac". In order to tell MobaXterm to preserve Windows PATH, you just have to go to "Settings" --> "Configuration" --> "Terminal" tab and check "Append Windows PATH environment variable" option.

Modify Virtualbox default VM path

At the same time, set VAGRANT_HOME to the new path.

Using Vagrant with CentOS 7

Browse the Vagrant Cloud for user-created base boxes you can use. For this example, we'll use "centos/7" which providing the command to start.

First of all, type the following:
vagrant init centos/7

Now that you have a vagrant file, you can spin up the VM with this command:
vagrant up --provider virtualbox

If you want to download the vagrant box directly, just find the box versions page, and append the strings [/providers/virtualbox.box] to the link address.

eg: https://atlas.hashicorp.com/centos/boxes/7/versions/1606.01/providers/virtualbox.box

Then, you can point to the folder where vagrant and copy the box file to same location. After you may run as follows:

vagrant box add custom-box-name name-of-the-box.box
vagrant init custom-box-name
vagrant up

Note:

  1. If you encounted the issue "could not be found or could not be accessed in the remote catalog", please refer to Can't download boxes on Windows 10
  2. The default memory is only 512, you'd better to adjust it in Vagrantfile
  3. Upgrade RHEL from 7.3 to 7.4: ArrayIndexOutOfBoundsException in sun.font.CompositeStrike.getStrikeForSlot If you get the trouble on setup Intellij idea like above, just run sudo yum install -y dejavu-sans-fonts to solve this issue.

Landing Vagrant

First, Type this to get your SSH info: vagrant ssh-config It will tell you the IP and SSH port to use and a few other bits of info.

Second, login the system via mobaxterm, and enter the follows in session settings:

  1. host ip
  2. username
  3. port
  4. private key

Now, you are in the system.

X11 Forwarding Configuration on Linux

# /etc/ssh/ssh_config for ssh client
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes
# /etc/ssh/sshd_config for ssh server
X11Forwarding yes
X11UseLocalhost no

Additional Notes

The “base” boxes are stored in the %userprofile%/.vagrant.d/boxes folder. These will be used over and over for any projects you create that use the same box.

If you destroy all VMs that use a certain box, this does not delete the box itself.

You can turn the VM off by using vagrant halt, or suspend it with vagrant suspend. Then turn it on again any time with vagrant up. Type vagrant status to see the current state of the VM.

All commands can be found here.

results matching ""

    No results matching ""