Vagrant - a quick how to

I must confess - I’m a Windows user :) Maybe it is not as cool as Linux or other operating systems, but it solves all the tasks I need so who cares. But there are some rare cases when it is easier for me to use Ubuntu.

Like when I took an online Docker course and had some issues with setting up Docker on Windows. I didn’t want to use raw VirtualBox or similar virtualization software because it is a good exercise to practice command line skills from time to time.

Vagrant is a command line tool to manage virtual machines so it fitted all my needs. I won’t cover the setup process here. You can download the latest version ang go through the installation process.

By the way I’m still using VirtualBox as an underlying layer for Vagrant as covered here.

So these are the basic Vagrant commands that I use to run Ubuntu or other virtual machines.

# Create folder
mkdir vagrant_folder
cd vagrant_folder

# Initialize Ubuntu box
vagrant init ubuntu/xenial64

# Start Vagrant, log in to Ubuntu, perform basic operation, log out.
vagrant up
vagrant ssh
sudo apt-get update
exit

# Pause machine
vagrant suspend

# Or stop machine
vagrant halt

# Delete machine
vagrant destroy

# Remove box file
vagrant box remove ubuntu/xenial64

There are a lot of other useful commands in Vagrant so I strongly recommend dig deeper into official documentation.

Comments

comments powered by Disqus