Docker vs Kubernetes
Building containers vs orchestrating them
Docker and Kubernetes operate at different levels of the container ecosystem. Docker is a tool for building and running individual containers. Kubernetes is a platform for orchestrating hundreds or thousands of containers across a cluster of machines. They're complementary, not competing technologies.
Docker
Docker is a platform for building, packaging, and running applications in containers — lightweight, isolated environments that bundle an application with its dependencies, libraries, and runtime. Created by Solomon Hykes in 2013, Docker popularized containerization by making it accessible through a simple CLI and Dockerfile format. A Docker container is a running instance of a Docker image, which is a read-only template built from a Dockerfile. Docker provides a consistent environment from development to production ('it works on my machine' solved), efficient resource usage (containers share the host OS kernel, unlike VMs), and fast startup times (seconds, not minutes). Docker Desktop, Docker Compose, and Docker Hub form the core ecosystem.
Kubernetes
Kubernetes (K8s) is an open-source container orchestration platform originally developed by Google and released in 2014. While Docker runs containers on a single machine, Kubernetes manages containers across a cluster of many machines. It handles scheduling (which node runs which container), scaling (adding or removing container instances based on load), self-healing (restarting failed containers, replacing unhealthy nodes), service discovery (how containers find each other), load balancing, rolling deployments, secret management, and storage orchestration. Kubernetes declares the desired state (via YAML manifests) and continuously works to maintain it. Managed offerings like EKS, GKE, and AKS handle the complex control plane infrastructure.
Key Differences
- **Scope**: Docker builds and runs individual containers. Kubernetes orchestrates many containers across a cluster. - **Scale**: Docker operates on a single machine. Kubernetes manages containers across hundreds of machines. - **Concern**: Docker answers 'how do I package and run this app?' Kubernetes answers 'how do I run 50 copies of this app reliably across 20 servers?' - **Complexity**: Docker has a gentle learning curve. Kubernetes is notoriously complex with a steep learning curve. - **Scheduling**: Docker Compose schedules containers on one host. Kubernetes schedules across a cluster with resource-aware bin-packing. - **Self-healing**: Docker restarts failed containers (with restart policies). Kubernetes replaces failed containers, reschedules workloads from dead nodes, and performs health-check-based remediation.
When to Use Each
**Use Docker** for local development, small applications, single-server deployments, CI/CD build steps, and learning about containers. Docker Compose is perfect for running multi-container apps (web + database + cache) on one machine. **Use Kubernetes** when you need to run containers at scale across multiple machines, require high availability and automatic failover, need zero-downtime deployments, or manage many microservices. But be honest about whether you need Kubernetes — many successful applications run on a single server with Docker Compose.
Analogy
**Docker** is like a shipping container — it packages your goods (application) in a standardized box that can run on any ship, truck, or crane (any server with Docker installed). You pack one container at a time. **Kubernetes** is like a shipping port authority — it manages thousands of containers across many ships, decides which container goes on which ship, replaces damaged containers, scales the fleet up during peak season, and ensures goods are delivered reliably. You need containers (Docker) before you need a port authority (Kubernetes).