← Back to Home
🐳

Introduction to Docker

The tool that ended 'but it works on my machine' forever.

9 min read📚DevOps Fundamentals

Before Docker, moving an app from a developer’s laptop to a production server was painful — different OS versions, missing libraries, mismatched configs. Docker packages your app and everything it needs into a single, portable unit called a container that runs the same way everywhere.


🎯 Learning Objectives

By the end of this lesson you will:


What is a Container?

A container is a lightweight, isolated environment that holds your application plus its dependencies (libraries, runtime, config). It shares the host’s operating system kernel but runs as if it had its own private machine.

💡 The lunchbox analogy

A container is like a sealed lunchbox: whatever you pack (your app + dependencies) travels together and arrives exactly as you packed it — no matter whose fridge (server) you put it in.


Containers vs Virtual Machines

Both isolate workloads, but they work very differently:

Container Virtual Machine
Contains App + dependencies A full guest OS + app
Size Megabytes Gigabytes
Startup Seconds or less Minutes
Isolation Process-level (shares host kernel) Full OS-level
Density Hundreds per host A handful per host
text
VM:         [App][Guest OS] [App][Guest OS]   ← heavy
           \_____ Hypervisor _____/

Container:  [App][App][App][App]             ← light
           \_____ Docker Engine ___/
           \_______ Host OS _______/

Containers are lighter and faster because they skip the extra guest operating system.


The Three Core Concepts

Concept What it is
Image A read-only template/blueprint (your app packaged up)
Container A running instance of an image
Registry A store for images (e.g. Docker Hub)

The relationship, in one line: you pull an image from a registry and run it to create a container.

text
Registry ──pull──▶ Image ──run──▶ Container

Run Your First Container

Docker Hub has a tiny test image called hello-world:

bash
docker --version              # check Docker is installed
docker run hello-world        # pull + run a test container
bash — 80×24
student@devops:~$docker run hello-world

Docker couldn’t find the image locally, so it pulled it from the registry, then ran it as a container. That’s the whole loop.


🧪 Hands-on Lab

📝

Run and Inspect a Real Container

  1. Run an Nginx web server container in the background on port 8080
  2. List the running containers
  3. Confirm it responds, then stop it

🧠 Knowledge Check

Knowledge Check

What is the main difference between a container and a virtual machine?

Knowledge Check

What is the relationship between an image and a container?


💼 Interview Preparation

Interview Q&A

Why did Docker become so important for DevOps?


Summary

You now understand containers, how they differ from VMs, and the image → container → registry model. Next, you’ll work hands-on with images and containers and learn the everyday Docker commands.

Up Next

Images & Containers in Practice

You've mastered this lesson. Continue your journey to becoming a DevOps Engineer.

Start Next Lesson