This repo is essentially just a collection of my notes/practice as I learn how to use Vagrant. I mostly learned by following https://www.vagrantup.com/docs/ and Googling random snippets online.
To get started:
- Download Vagrant from https://www.vagrantup.com/downloads.html.
- Download VirtualBox from https://www.virtualbox.org/.
git clonethis repository.cdinto your local clone of this repository.- Run
vagrant up. - Afterwards, run
vagrant ssh- If you run into any issues over port 4567, you're likely running another
vagrant instance that's using the same port. You can either run destroy the
other vagrant instance or modify the
Vagrantfileto avoid this port reusage issue.
- If you run into any issues over port 4567, you're likely running another
vagrant instance that's using the same port. You can either run destroy the
other vagrant instance or modify the
- After you successfully ssh into your virtual machine, your working directory
will already have been changed to
/code(on your guest machine).- Your host machine (where you ran
vagrant sshfrom) and guest machine (the Ubuntu instance accessed viavagrant ssh) will have synced folders. - Your host machine's
../directory (the directory in which your clonedlets-learn-vagrantrepo is located in) is connected to... - Your guest machine's
/codedirectory. - Any changes on the host machine's synced folder will be reflected on the guest machine's synced folder.
- Any changes on the guest machine's synced folder will be reflected on the host machine's synced folder.
- Your host machine (where you ran
- Run
cd lets-learn-vagrantandnode index.jsfrom your guest machine. - Navigate to http://localhost:4567/ via a browser from your host machine.
- If you can see a web page there, you've succeeded!
Notes:
- You can have multiple terminal sessions from your host machine
cdinto the directory with theVagrantfileand runvagrant ssh. - You can have a single terminal session pop out of a virtual machine session
via
exitfrom the guest machine's terminal. - You can run
vagrant destroyfrom the host machine's terminal (from the directory wherevagrant upandvagrant sshwere initially run) to get rid of your virtual machine session, and free up any associated memory from your host machine. - The virtual machine is running Ubuntu v12.04 (aka Linux)! Command line tools
like
breware not included in this vagrant setup. Here,apt-getis your friend.