RousselTMLEARNING

TP · Vagrant: From Discovery to Expertise

Lab: My first virtual machine with Vagrant

What you will learn in this TP
  • Create a VM from a Vagrantfile
  • Use the shared folder and port forwarding
  • Destroy cleanly

Creating the machine #

What you will learn in this section
  • Create a VM from a Vagrantfile
  • Use the shared folder and port forwarding
  • Destroy cleanly

Context. You join a project whose dev environment is installed from a 40-line wiki page nobody can follow. Vagrant describes the machine in a file and recreates it identically with one command: you start with the simplest machine.

Prerequisites: VirtualBox (or libvirt) and Vagrant installed  ·  Estimated time: 25 min

From Vagrantfile to a running machine.
  1. 1. Initialise the project

    Why? The Vagrantfile is the single source of truth: the whole team gets the same machine from the same versioned file.

    Create a working folder and generate a Vagrantfile based on the bento/ubuntu-24.04 box.
  2. 2. Start and connect

    Why? Starting then connecting checks the box, provider and network work before investing time in configuration.

    Start the machine, open an SSH session and check the system.
  3. 3. Shared folder and network

    Why? The shared folder avoids copying code into the VM, and port forwarding lets you test from your browser like a real application.

    Serve a file from the project folder inside the VM and expose port 8080 on the host.
  4. 4. Clean up

    Why? Destroying the machine is normal: reproducibility means you can recreate it anytime, the downloaded box staying cached.

    Stop then remove the machine. What remains on disk?

Difficulty level : ●○○○○ (1/5)

My progress

  • ⏱ Estimated time : ≈ 25 min

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

Vagrant multi-machine: deploying a ready-to-use Docker Swarm cluster

Use a single Vagrantfile to build a three-node Docker Swarm cluster (one manager, two workers) wi...

Vagrant best practices: reproducible and fast environments

Vagrant best practices: versioned Vagrantfile, pinned boxes, idempotent provisioning, multi-machi...

Vagrant plugins: extending providers, provisioners and commands

Understand Vagrant's plugin system: what a plugin can add (provider, provisioner, command, capabi...

Vagrant: overview and vocabulary (box, provider, provisioner, Vagrantfile)

The essential notions for following the Vagrant course: what Vagrant is for, the lifecycle of an ...

Sharing a Vagrant environment: ngrok and the vagrant-share plugin

Make an application running in a Vagrant machine accessible to a colleague or a client: port forw...

Compute on Azure: virtual machines, App Service, Functions and containers

Choose and use Azure compute: virtual machines and scale sets (VMSS), App Service, Azure Function...

Docker: overview, architecture and first steps

Discover Docker: containers vs virtual machines, client/daemon/registry architecture, images and ...

Kibana: role, installation and first steps

What Kibana is in the Elastic suite, how to install it with Elasticsearch (start-local, Docker), ...

Containers, Kubernetes and cloud native in a DevOps approach

The role of containers and Kubernetes in DevOps: reproducible images, multi-stage Dockerfiles, re...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!