What is Docker?

Docker packages your application and all its dependencies into a container — a lightweight, portable unit that runs the same everywhere.

The problem Docker solves

"It works on my machine" is the most common phrase in development. Docker eliminates this by ensuring your app runs in the same environment everywhere — your laptop, a colleague's machine, staging, production.

Key concepts

Image — A read-only template with everything needed to run your app (code, runtime, libraries, env vars). Like a class in OOP.

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

Dockerfile — A recipe that defines how to build an image.

Registry — A storage for images (Docker Hub, GitHub Container Registry).

Installing Docker

bash
# macOS / Windows
# Download Docker Desktop from docker.com

# Ubuntu
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

# Verify
docker --version
docker run hello-world

Your first container

bash
# Run an Nginx web server
docker run -d -p 8080:80 nginx

# Visit http://localhost:8080 — you have a web server!

# See running containers
docker ps

# Stop it
docker stop <container-id>