The primary goals of this experiment are:
| Feature | Virtual Machine (VM) | Container | | :— | :— | :— | | Virtualization Level | Emulates complete hardware and kernel. | Virtualizes at the OS level, sharing the host kernel. | | Isolation | Strong (Full OS isolation). | Moderate (Process-level isolation). | | Resource Usage | Higher (Requires dedicated RAM/CPU for guest OS). | Lightweight and efficient. | | Startup Time | Slower (Minutes/Seconds). | Fast (Milliseconds/Seconds). |
Using Vagrant, an Ubuntu VM was initialized and started.
vagrant init ubuntu/jammy64 followed by vagrant up.
Observation: The system downloads the base box (Ubuntu Jammy) and configures the VirtualBox provider. Port forwarding (2222 -> 22) is established.
Once the VM was up, we established a connection to the guest OS.
vagrant ssh
Observation: Successful login to the Ubuntu 22.04.5 LTS environment.
Inside the VM terminal, the package lists were updated, and the Nginx web server was installed.
sudo apt update, sudo apt install -y nginx
Observation: The
aptpackage manager retrieves necessary archives. This process is slower than Docker as it installs dependencies for a full OS environment.

Observation: Installation is complete. Triggers for
man-dbandufware processed.
We verified the server was running locally within the guest OS.
curl localhost
Observation: The
curlcommand inside the VM returns the full HTML source of the “Welcome to nginx!” page.
The Docker engine was used to pull the Ubuntu image and deploy a containerized Nginx instance.
docker run -dp 8080:80 --name nginx-container nginx
Observation: Docker pulls the image layers and starts the container nearly instantaneously.
The Nginx server was verified by accessing the mapped port on the localhost.
curl localhost:8080
Observation: The
curlcommand confirms the Nginx “Welcome” page is active on port 8080.
This section uses specific metrics captured during the experiment to contrast the two technologies.
systemd-analyze
Observation (VM): The VM took 36.819 seconds to finish startup (6.9s kernel + 29.8s userspace). Observation (Container): The container started in less than 1 second (refer to Docker output in Sec 5).
htop
Observation (VM):
htopreveals a heavy process tree. Even though we only want Nginx, the VM is runningsystemd,snapd,rsyslogd,polkitd, andsshd. There are dozens of tasks running to support the OS.

Observation (Container):
docker statsshows the container uses minimal resources because it only runs the application process (Nginx) and its direct dependencies.

Observation (VM): The
free -hcommand inside the VM shows it has allocated 957Mi total, with 196Mi used immediately by the OS kernel and services.
Observation (Container): Referring to the Docker Stats image above, the container consumes only 13.22MiB of RAM.
| Parameter | Virtual Machine (VM) | Container (Docker) |
|---|---|---|
| Boot Time | ~36.8 seconds (Measured) | < 1 second |
| RAM Usage | ~196 MiB (Base OS overhead) | ~13.22 MiB (App only) |
| Background Processes | High (init, systemd, ssh, logs) | Low (only Nginx entrypoint) |
| Disk Usage | Larger (Full OS libraries) | Smaller (Layered Image) |
The experiment validates that Containers are significantly more lightweight.
htop analysis clearly shows that VMs run a full operating system stack, creating unnecessary overhead for single-application deployments.Therefore, Containers are ideal for microservices and rapid scaling, while VMs are better suited for scenarios requiring full hardware simulation or complete OS isolation.