I remember staring at a Kubernetes YAML file for the first time and thinking: what is any of this? Terms like Pods, Nodes, Deployments, ReplicaSets, and Services were stacked on top of each other with no obvious entry point. I had no idea where Docker ended and Kubernetes began.
What I eventually figured out — after a lot of trial and error — is that these two tools aren’t nearly as complicated as they first appear. Docker solves a very specific problem. Kubernetes solves a different but related one. Once you understand what each tool is actually for, everything else clicks into place.
This guide is what I wish I had when I started. You’ll learn what Docker and Kubernetes are, how they work together, how they run in the cloud, and how to think about the whole system — without needing a computer science degree or three years of DevOps experience.
What Is Docker? (And Why Does It Exist?)
Before Docker, deploying software was a constant battle with environments.
You’d write code that worked perfectly on your laptop. Then you’d hand it to a colleague and it would break. Then it would break again in production. The culprit was almost always the environment — different operating system versions, different library versions, different configurations.
Docker solves this problem with containers.
A container is a lightweight, portable, self-contained package that bundles your application together with everything it needs to run: the code, the runtime, the system libraries, and the configuration. When you ship a container, the environment comes with it.
Think of it like a shipping container for software. A shipping container can hold any kind of cargo and fits onto any ship, truck, or train without modification. Docker containers work the same way — they run the same on your laptop, your colleague’s laptop, a test server, or a production cloud environment.
Key Docker Concepts
Image: A Docker image is a read-only template — the blueprint for a container. It defines what your app needs: base operating system, dependencies, code, startup command. Images are built using a file called a Dockerfile.
Container: A running instance of an image. You can run many containers from the same image. Each one is isolated from the others.
Dockerfile: A text file with instructions for building your image. Each line adds a layer. Here’s a simple example:
dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]This file says: start from a Node.js base image, copy the code, install dependencies, expose port 3000, and run the server. Docker takes these instructions and builds an image you can deploy anywhere.
Docker Hub: A public registry where Docker images are stored and shared. You can pull official images for popular software like Nginx, PostgreSQL, Redis, and Node directly from Docker Hub, or push your own images there.
What Docker Doesn’t Do
Docker is excellent at packaging and running individual containers. But it doesn’t answer some critical questions for production:
- What happens if a container crashes?
- How do you run 50 containers across 10 servers?
- How do you update containers without downtime?
- How do you route traffic across multiple running containers?
That’s exactly where Kubernetes comes in.
What Is Kubernetes?
Kubernetes — often shortened to K8s (because there are 8 letters between the K and the s) — is an open-source container orchestration platform. It automates the deployment, scaling, and management of containerized applications.
Where Docker helps you package and run a single container, Kubernetes helps you run and manage hundreds or thousands of containers across many machines — reliably, automatically, and at scale.
Originally built by engineers at Google based on internal systems they’d been running for years, Kubernetes was open-sourced in 2014 and is now maintained by the Cloud Native Computing Foundation (CNCF). It has become the standard for running containers in production.
What Kubernetes Gives You
- Automatic restarts: If a container crashes, Kubernetes detects it and starts a new one automatically.
- Horizontal scaling: Need more capacity? Kubernetes can spin up additional container replicas automatically when traffic spikes.
- Rolling updates: You can update your application with zero downtime. Kubernetes replaces containers gradually, one at a time.
- Load balancing: Traffic is distributed across multiple running containers automatically.
- Self-healing: If a node (server) goes down, Kubernetes reschedules the affected workloads onto healthy nodes.
- Declarative configuration: You describe the desired state of your application in YAML files. Kubernetes continuously works to make reality match that description.
Kubernetes Architecture Explained
Understanding Kubernetes starts with understanding how it’s structured. Every Kubernetes environment is organized as a cluster — a set of machines working together.
The Control Plane (The Brain)
The Control Plane is the decision-making layer. It manages the cluster and keeps things running as you’ve defined them. It includes:
- API Server (kube-apiserver): The single front door to your cluster. Everything communicates through it — your commands, your CI/CD pipeline, internal components. If the API Server is down, you can’t make changes, but running workloads keep going.
- etcd: A distributed key-value store that holds the entire state of the cluster. Think of it as Kubernetes’ memory — it stores every configuration, every resource definition, every piece of state.
- Scheduler: Decides which worker node a new Pod should run on, based on available resources and constraints.
- Controller Manager: Watches the state of the cluster and takes action when the current state doesn’t match the desired state. For example, if you said “run 3 copies of this app” and one crashes, the Controller Manager notices and tells the Scheduler to start a new one.
In managed cloud Kubernetes services (like EKS, AKS, and GKE), the cloud provider runs and manages the Control Plane for you. You never touch it directly.
Worker Nodes (Where Your App Runs)
Worker Nodes are the machines — virtual or physical — where your containerized workloads actually run. Each node includes:
- Kubelet: The agent on every node that communicates with the Control Plane. It receives instructions and ensures the right containers are running on the node.
- Kube-proxy: Handles networking rules on the node, ensuring traffic flows correctly between Pods and Services.
- Container Runtime: The software that actually runs containers. Modern Kubernetes clusters use containerd or CRI-O — not Docker directly. You can still build your images with Docker, but Kubernetes runs them through these lighter-weight runtimes.
The Key Objects You’ll Work With
Pod: The smallest deployable unit in Kubernetes. A Pod wraps one or more containers that share the same network and storage. Most Pods contain a single container. Pods are ephemeral — if one dies, Kubernetes creates a replacement rather than repairing the original.
Deployment: The most common way to run an application. A Deployment defines how many replicas of a Pod to run and manages rolling updates. You rarely interact with Pods directly — you create a Deployment, and it manages the Pods for you.
ReplicaSet: A Deployment creates and manages a ReplicaSet, which maintains the correct number of running Pod replicas. You usually don’t manage ReplicaSets directly.
Service: Pods come and go — their IP addresses change constantly. A Service provides a stable IP address and DNS name, and routes traffic to the correct Pods. Think of a Service as the stable front door to a group of Pods.
Namespace: A way to divide cluster resources between multiple teams or environments. You might have dev, staging, and prod namespaces in a single cluster.
ConfigMap and Secret: ConfigMaps store configuration data (like environment variables or config files). Secrets store sensitive data like passwords, API keys, and certificates.
The typical flow looks like this:
User request → Service → Pods (managed by Deployment) → NodeDocker and Kubernetes Together: How They Work
It’s a common question: do you need Docker to use Kubernetes?
The short answer: you need container images. Docker is the most popular tool for building them, so yes — most people use Docker to build images, push them to a registry (like Docker Hub or a cloud registry), and then Kubernetes pulls and runs those images.
Here’s the typical workflow:
- You write your application code
- You write a Dockerfile describing how to build the container image
- You build the image with
docker buildand push it to a registry - You write a Kubernetes Deployment YAML that references your image
- You apply the YAML to your Kubernetes cluster with
kubectl apply - Kubernetes pulls the image and runs your Pods across the cluster
Docker is the packaging tool. Kubernetes is the deployment and operations platform. Together, they cover the full lifecycle from code to running production service.
Kubernetes on the Cloud: Managed Services Explained
Running Kubernetes yourself — setting up the Control Plane, managing etcd, handling upgrades, maintaining node availability — is complex work. For most teams, especially beginners, the better path is a managed Kubernetes service.
The three major cloud providers each offer one:
Amazon Elastic Kubernetes Service (EKS)
EKS is the most widely used managed Kubernetes service in the world. It integrates deeply with the AWS ecosystem — IAM for access control, ALB for load balancing, EBS and EFS for storage, CloudWatch for monitoring.
EKS is mature and battle-tested, but it requires more manual configuration than the other options. It doesn’t include as many pre-configured defaults, which gives you more control but also more work upfront.
Best for: Teams already using AWS, or organizations that need deep AWS integration and a large ecosystem of tooling.
Azure Kubernetes Service (AKS)
AKS is Microsoft’s managed Kubernetes offering. It integrates with Azure Active Directory, Azure DevOps, Azure Monitor, and the broader Microsoft ecosystem. One notable advantage: AKS doesn’t charge for the Control Plane — you only pay for the worker nodes you use.
AKS is generally considered the easiest of the three to get started with, and it’s a natural choice if your organization is already invested in Microsoft Azure.
Best for: Teams in the Microsoft/Azure ecosystem, organizations with existing Azure services and infrastructure.
Google Kubernetes Engine (GKE)
GKE was built by the company that invented Kubernetes, and it shows. It has the most advanced autoscaling capabilities, the fastest adoption of new Kubernetes versions (typically within 2 weeks of upstream release), and the most automated management. GKE Autopilot takes managed Kubernetes even further — Google manages both the Control Plane and the worker nodes, and you simply deploy workloads.
Best for: Teams prioritizing automation, machine learning workloads, or teams that want Google’s Kubernetes expertise baked in.
Which Should You Choose?
For beginners, the honest answer is: use whichever cloud platform you’re already on. If you’re in AWS, use EKS. If you’re in Azure, use AKS. If you’re on Google Cloud, use GKE. The core Kubernetes experience is the same across all three — Pods, Deployments, Services, and YAML files work identically. The differences show up in integrations, pricing, and advanced features.
Your First Kubernetes Deployment: Step by Step
Here’s a simple walkthrough of what deploying an application to Kubernetes actually looks like. You’ll need kubectl installed and connected to a cluster (a local Minikube cluster works for learning).
Step 1: Write a Deployment YAML
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: nginx:latest
ports:
- containerPort: 80This tells Kubernetes: run 3 replicas of an Nginx container. If any replica fails, replace it automatically.
Step 2: Apply the Deployment
bash
kubectl apply -f deployment.yamlKubernetes reads the YAML, stores it as the desired state, and starts creating Pods.
Step 3: Check That It’s Running
bash
kubectl get pods
kubectl get deploymentsYou’ll see three Pods running, each with a unique name.
Step 4: Expose It with a Service
yaml
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 80
type: LoadBalancerbash
kubectl apply -f service.yamlThis creates a Service that load-balances traffic across your three Pods. On a cloud cluster, it will provision an external load balancer automatically.
Step 5: Scale Up or Down
bash
kubectl scale deployment my-app --replicas=5Kubernetes adds two more Pods immediately. Scale back down anytime with the same command.
Common Beginner Mistakes to Avoid
Learning Docker and Kubernetes comes with a few predictable pitfalls. Here’s what to watch out for:
- Skipping Docker basics before jumping to Kubernetes. You can’t orchestrate what you don’t understand. Learn Docker first — images, containers, Dockerfiles, registries — before touching Kubernetes.
- Trying to learn both at the same time. Take them sequentially. Spend a week on Docker, then move to Kubernetes. Trying to absorb both simultaneously leads to confusion.
- Using the default Namespace for everything. Use separate namespaces for
dev,staging, andprodfrom the start. It keeps environments clean and makes access control easier. - Ignoring resource requests and limits. Always set CPU and memory requests and limits on your containers. Without them, a single misbehaving Pod can starve others on the same node.
- Over-sizing from the start. Beginners often provision far more than they need. Start small, measure your actual resource usage, then scale.
- Not setting up health checks. Kubernetes uses liveness and readiness probes to know whether a container is healthy. Without them, Kubernetes can’t tell the difference between a starting container and a broken one.
Useful Tools to Know
As you go deeper, these tools will make your Kubernetes workflow significantly easier:
- Minikube / Kind: Run a local Kubernetes cluster on your laptop. Essential for learning and development without cloud costs.
- kubectl: The command-line tool for interacting with Kubernetes clusters. You’ll use this constantly.
- Helm: A package manager for Kubernetes. Helm Charts let you install and manage complex applications (like databases or monitoring stacks) with a single command.
- k9s: A terminal UI for navigating Kubernetes clusters in real time. Much faster than typing kubectl commands repeatedly.
- Lens: A desktop GUI for managing Kubernetes clusters visually.
- Docker Desktop: Includes a local single-node Kubernetes cluster. Easy way to start experimenting on your laptop.
FAQ
Do I need to learn Docker before Kubernetes?
Yes, and it will make your Kubernetes journey significantly smoother. Docker gives you the foundational understanding of containers, images, and Dockerfiles that Kubernetes builds on. Trying to learn Kubernetes without Docker basics leads to confusion about where the problems are coming from.
Is Kubernetes only for large companies?
Not at all. Kubernetes has become more accessible over time, and managed cloud services have dramatically reduced the operational complexity. Small teams and startups use Kubernetes regularly, especially through fully managed options like GKE Autopilot or AKS, where infrastructure management is minimal.
What is the difference between a Pod and a container?
A container is the running instance of a Docker image. A Pod is the smallest unit Kubernetes manages — it wraps one or more containers that share the same network namespace and storage. In practice, most Pods contain a single container. Kubernetes schedules and manages Pods, not individual containers.
Can Kubernetes run without Docker?
Yes. Kubernetes uses a container runtime interface (CRI) to run containers, and modern clusters use containerd or CRI-O as the runtime rather than Docker directly. You can still build your images with Docker — it’s just not the runtime Kubernetes uses to run them.
How do I practice Kubernetes without spending money on cloud resources?
Use Minikube or Kind to run a local Kubernetes cluster on your laptop for free. Both create a single-node cluster in minutes. Most cloud providers also offer free tiers or free trial credits that let you spin up a managed Kubernetes cluster for learning at minimal cost.
What is Helm and do I need it?
Helm is a package manager for Kubernetes. It lets you install complex applications using pre-built “Charts” rather than writing all the YAML yourself. It’s not required for beginners, but it becomes very useful as soon as you need to deploy standard infrastructure like Prometheus, Grafana, Ingress controllers, or databases.
What is the difference between EKS, AKS, and GKE?
All three are managed Kubernetes services that run the same core Kubernetes. The differences are in cloud ecosystem integration, pricing, and automation level. EKS integrates with AWS, AKS integrates with Azure (and doesn’t charge for the Control Plane), and GKE is built by Google — the creator of Kubernetes — and offers the most advanced automation and autoscaling. For beginners, use whichever matches your existing cloud provider.
Final Thoughts
Docker and Kubernetes on cloud can feel overwhelming at first — but the underlying logic is clean once you understand it.
Docker solves the “works on my machine” problem by packaging your application and its environment together into a portable container. Kubernetes solves the “runs reliably in production” problem by automating deployment, scaling, self-healing, and load balancing across a cluster of machines. Cloud-managed services like EKS, AKS, and GKE make it possible to use Kubernetes without running the infrastructure yourself.
The learning path is straightforward:
- Learn Docker — build images, run containers, understand Dockerfiles
- Learn Kubernetes basics — Pods, Deployments, Services, kubectl
- Practice locally with Minikube or Kind
- Deploy to a managed cloud cluster
- Add Helm, monitoring, and more advanced features as needed
Take it step by step. Break things in a local environment where the cost is nothing and the lessons are real. Every engineer who works with Kubernetes today started at exactly the same place you are now — with a YAML file that made no sense and a willingness to figure it out.
