01-What is Docker?
DockerContainersDevOps Beginner 3 min read

01-What is Docker?

Understand what Docker is, why it exists, and how it solves the 'it works on my machine' problem with containerization.

The Problem Docker Solves

You’ve probably heard the classic developer complaint: “It works on my machine!” — but breaks in staging, production, or on a teammate’s laptop.

This happens because applications depend on:

  • Specific OS libraries
  • Runtime versions (Node 18 vs Node 20)
  • Environment variables
  • File paths and configs

Docker solves this by packaging your app and all its dependencies into a single portable unit called a container.

Key Insight
A container is like a lightweight, self-contained box that holds your app + everything it needs to run — and it runs identically everywhere.

Docker vs Virtual Machines

Many people confuse Docker containers with virtual machines (VMs). Here’s the key difference:

FeatureVirtual MachineDocker Container
OSFull OS per VMShares host OS kernel
SizeGBsMBs
Startup timeMinutesSeconds
Resource usageHeavyLightweight
PortabilityLimitedExcellent
Use caseFull OS isolationApp isolation

Containers are not VMs. VMs virtualise hardware; containers virtualise the OS process space.

Docker Architecture

Docker uses a client–server architecture:

┌─────────────────────────────────────────────┐
│              Docker Host (your machine)      │
│                                             │
│  ┌──────────┐        ┌──────────────────┐   │
│  │  Docker  │  REST  │   Docker Daemon  │   │
│  │  Client  │◄──────►│   (dockerd)      │   │
│  │  (CLI)   │  API   │                  │   │
│  └──────────┘        └────────┬─────────┘   │
│                               │             │
│               ┌───────────────┼───────────┐ │
│               │               │           │ │
│          ┌────▼───┐   ┌───────▼──┐  ...   │ │
│          │  C1    │   │   C2     │        │ │
│          └────────┘   └──────────┘        │ │
└─────────────────────────────────────────────┘
         ▲
         │ docker pull / push
         ▼
   ┌──────────────┐
   │ Docker Hub   │
   │ (Registry)   │
   └──────────────┘

Three main components:

  • Docker Client — the docker CLI you type commands into
  • Docker Daemon (dockerd) — the background service that does the actual work
  • Docker Registry — stores Docker images (Docker Hub is the default public registry)

Installing Docker

macOS / Windows

Download Docker Desktop from docker.com — it includes Docker Engine, CLI, and Docker Compose.

Ubuntu / Debian

# Remove old versions
sudo apt-get remove docker docker-engine docker.io containerd runc

# Install prerequisites
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg

# Add Docker's official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
  sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

# Set up the repository
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker Engine
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

# Add your user to the docker group (no more sudo)
sudo usermod -aG docker $USER
newgrp docker

Verify Installation

docker --version
# Docker version 26.1.0, build a0fcdb4

docker run hello-world
# Pulls the hello-world image and runs it

You should see: “Hello from Docker!”

Pro Tip
Run docker run hello-world after every fresh install to confirm Docker can pull from Docker Hub and run containers.

Core Vocabulary

TermWhat it means
ImageRead-only blueprint for a container (like a class in OOP)
ContainerA running instance of an image (like an object)
DockerfileInstructions to build a custom image
RegistryStorage for images (Docker Hub, ECR, GCR)
VolumePersistent storage that survives container restarts
NetworkVirtual network connecting containers

Summary

  • Docker packages apps + dependencies into containers
  • Containers are lightweight (share host OS kernel) unlike VMs
  • Docker uses a client–server architecture (CLI → daemon)
  • Images are blueprints; containers are running instances

You’re ready to start building your first container in the next lesson!