This tutorial is oriented at people who are just beginning to explore web development.
Vagrant is a command line application for creating isolated machine environments called "boxes". It works by creating virtual infrastructure using "providers" such as VirtualBox, VMWare, Parallels, or Docker, among others. This tutorial uses the Docker provider which works on Apple's new M1 processor. The Vagrant setup described in this guide will work on any platform but the installation of Vagrant and Docker will vary by host OS.
Prerequisites
Basic familiarity with the command line. Tania Rascia has an excellent tutorial.
Homebrew
Install Homebrew by pasting the command show on the home page into your macOS Terminal prompt.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install Vagrant.
brew install vagrant
Docker
Docker can also be installed via Homebrew.
brew install --cask docker
Start Docker.
Using Vagrant
In a new folder, create a new file with the name Vagrantfile
. It should contain the following Vagrant configuration:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.hostname = "ubuntu"
config.vm.provider :docker do |docker, override|
override.vm.box = nil
docker.image = "cg433n/ruby:0.1"
docker.remains_running = true
docker.has_ssh = true
docker.privileged = true
docker.volumes = ["/sys/fs/cgroup:/sys/fs/cgroup:ro"]
end
end
At the command line, run vagrant up
. When the command completes, enter your new development box by running vagrant ssh
.
Installing Jekyll
Now that you have logged in to your Vagrant box, install Jekyll. Follow along with the official documentation but skip the first step - your Vagrant box comes with the prerequisites already installed.
From this point on, you should be able to explore Jekyll on your own.
- Check out the official Jekyll tutorials.
- Learn more about Vagrant - especially how to start, enter, and teardown environments.
Credit
This Vagrant configuration is adapted from work by John Rofrano.