Skip to main content
Docker beginner Lesson 1 of 9

Introduction to Docker

What Docker is, why it exists, how containers differ from VMs, and how to install Docker on your machine.

What Is Docker?

Docker is a platform that packages applications into containers — isolated, portable units that include everything the app needs to run: code, runtime, libraries, and configuration. A container built on your laptop runs identically in CI, staging, and production.

Theory first: containerization as standardization

Docker’s core value is operational standardization: the same artifact should behave the same way across dev, CI, and production. The container is the contract between application code and the runtime environment.

When you see Docker through that lens, image design, dependency pinning, and runtime configuration become reliability decisions—not just tooling steps.

Without Docker                    With Docker
──────────────────────            ──────────────────────────────
Developer laptop:                 Developer laptop:
  Node 18, Ubuntu 22.04           ┌─────────────────────────┐
  npm 9.x                         │  Container              │
  works ✓                         │  Node 18 + npm 9 + app  │
                                  └─────────────────────────┘
Production server:                                │
  Node 16, CentOS 7                              ▼
  npm 8.x                         Production server:
  breaks ✗                          runs same container ✓

Containers vs Virtual Machines

ContainerVirtual Machine
OS kernelShared with hostFull separate kernel
Startup timeMillisecondsMinutes
SizeMBsGBs
IsolationProcess-levelHardware-level
PerformanceNear-native~10–20% overhead

Containers are not more or less secure than VMs by default — they trade hardware isolation for speed and density. Most production systems run containers inside VMs for both benefits.

Core Concepts

Image — a read-only blueprint. Think of it like a class in OOP.

Container — a running instance of an image. Like an object instantiated from a class.

Dockerfile — a script of instructions that builds an image.

Registry — a storage server for images. Docker Hub is the public default; you can also run private registries.

Layer — each instruction in a Dockerfile creates a cached layer. Layers are shared across images to save disk space.

Dockerfile
    │  docker build

Image (layers stacked)
    │  docker run

Container (image + writable layer)

Installing Docker

Windows / macOS

Download and install Docker Desktop from docker.com. It includes Docker Engine, Docker Compose, and a GUI dashboard.

Linux (Ubuntu/Debian)

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

# Install using the official script
curl -fsSL https://get.docker.com | sh

# Add your user to the docker group (avoids sudo on every command)
sudo usermod -aG docker $USER

# Log out and back in, then verify
docker --version

Your First Container

# Pull and run the official hello-world image
docker run hello-world

# Run an interactive Ubuntu shell (--rm removes the container on exit)
docker run --rm -it ubuntu bash

# Inside the container:
cat /etc/os-release   # confirms you're in Ubuntu
exit                  # back to your host

Verifying the Installation

docker version          # client and server versions
docker info             # system-wide info: containers running, images, storage driver
docker run hello-world  # pulls image from Docker Hub and runs it

Expected output from hello-world:

Hello from Docker!
This message shows that your installation appears to be working correctly.

Learning Roadmap

LevelTopics
BeginnerImages, containers, Dockerfiles, basic CLI
IntermediateNetworking, volumes, Docker Compose
AdvancedMulti-stage builds, security hardening, production patterns, registries

Frequently Asked Questions

What problem does Docker solve?
The classic 'it works on my machine' problem. Docker packages your app and everything it needs — runtime, libraries, config — into a container that runs identically on any machine with Docker installed.
Is Docker the same as a virtual machine?
No. A VM emulates an entire computer including the OS kernel. A container shares the host OS kernel and only isolates the process and filesystem. Containers start in milliseconds and use far less memory.
Do I need to know Linux to use Docker?
Basic Linux command-line knowledge helps since most Docker images are Linux-based, but Docker Desktop on Mac and Windows handles the Linux VM for you automatically.