What is Kubernetes and how does it relate to Docker?
Fast recall
Quick revision
Core answer
Interview-ready guide
Interview answer
Docker and Kubernetes work at different layers. Docker provides tools to build container images and an engine that can run containers. Kubernetes is a cluster orchestrator: I declare a workload such as a Deployment, and Kubernetes schedules Pods, replaces failed instances, performs rolling updates, and connects them through Services.
For example, I can build orders:1.4 with Docker and push it to a registry. A Kubernetes Deployment references that image and asks for three replicas. Nodes pull the image and a container runtime starts the containers.
Kubernetes does not simply manage 'Docker containers.' Modern Kubernetes uses the Container Runtime Interface with runtimes such as containerd or CRI-O; the built-in Docker integration called dockershim was removed in version 1.24. Docker-built OCI images remain usable. The simple distinction is: image/container tooling versus multi-node workload orchestration.
What is Kubernetes and how does it relate to Docker
Direct Answer
Kubernetes is an orchestration system for running containerized workloads across cluster nodes. Docker is a toolchain and engine for building images and running containers. Kubernetes consumes OCI-compatible images through CRI-compatible runtimes such as containerd or CRI-O; it does not require Docker Engine, and its built-in dockershim was removed in Kubernetes 1.24.
Code Example
# Docker builds and runs ONE container on ONE machine:
# docker build -t order-service:1.0 .
# docker run -d -p 8080:8080 order-service:1.0
# Kubernetes runs MANY containers across a cluster, declaratively:
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-service
spec:
replicas: 3 # K8s keeps 3 instances running
selector:
matchLabels: { app: order-service }
template:
metadata:
labels: { app: order-service }
spec:
containers:
- name: order-service
image: order-service:1.0 # the SAME image you built with Docker
ports:
- containerPort: 8080
# kubectl apply -f deployment.yaml -> K8s schedules, scales, and self-heals
Common Mistakes & Pitfalls
- Saying Kubernetes requires Docker Engine: it uses a CRI runtime; Docker-built images remain compatible.
- Expecting controller-driven restart/replacement to fix application logic: Kubernetes can restart/replace a container, not repair bad data or code.
- Calling replicas automatically scaled: configure an autoscaler and metrics/limits.
- Choosing Kubernetes from resume value alone: include platform ownership and operational cost.
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.