Docker Kubernetes
24 interview questions and answers in the Docker Kubernetes section.
Questions in this section
- What is containerization and why is it needed?
- What is the difference between container and virtual machine?
- What is Dockerfile?
- What are the main instructions used in Dockerfile?
- What is the difference between CMD and ENTRYPOINT?
- What is multi-stage build?
- What is Docker Compose?
- What is Kubernetes and why is it needed?
- What is Pod in Kubernetes?
- What is Node in Kubernetes?
- What is Service in Kubernetes?
- What types of Service exist (ClusterIP, NodePort, LoadBalancer)?
- What is ReplicaSet?
- How does scaling work in Kubernetes?
- What is HorizontalPodAutoscaler (HPA)?
- What is the Difference Between ConfigMap and Secret?
- What is Liveness Probe?
- What is Readiness Probe?
- Why are Health Checks Needed in Kubernetes?
- What is Ingress in Kubernetes?
- What is Namespace in Kubernetes?
- How to Organize Rolling Update in Kubernetes?
- What is StatefulSet and When to Use It?
- How to Monitor Applications in Kubernetes?
Study navigator
24 questions for preparing for a Middle Java Developer interview.
All Questions
Topic Dependency Map
┌──────────────────────────────────────────┐
│ DOCKER BASICS (1-7) │
│ 1. Containerization │
│ 2. Container vs VM │
│ 3. Dockerfile │
│ 4. Dockerfile Instructions │
│ 5. CMD vs ENTRYPOINT │
│ 6. Multi-stage build │
│ 7. Docker Compose │
└──────────────────┬───────────────────────┘
│
┌──────────────────────────┼──────────────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌────────────────────┐
│ K8s BASICS │ │ K8s NETWORK │ │ K8s SCALING │
│ (8-13) │ │ (11-12, 20) │ │ (14-15, 22) │
│ 8. K8s overview│ │ 11. Service │ │ 14. Scaling │
│ 9. Pod │ │ 12. Svc Types │ │ 15. HPA │
│ 10. Node │ │ 20. Ingress │ │ 22. Rolling update │
│ 13. ReplicaSet │ │ │ │ │
└───────┬───────┘ └───────┬───────┘ └────────┬───────────┘
│ │ │
└────────────────────────┼────────────────────────┘
▼
┌──────────────────────────────────────────┐
│ K8s CONFIG & HEALTH (16-21) │
│ 16. ConfigMap vs Secret │
│ 17. Liveness probe │
│ 18. Readiness probe │
│ 19. Health checks │
│ 21. Namespace │
└──────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────┐
│ STATEFUL & MONITORING (23-24) │
│ 23. StatefulSet │
│ 24. Monitoring │
└──────────────────────────────────────────┘
Recommended Study Order
Junior Level (weeks 1-2)
| Step | Topic | Files | Goal |
|---|---|---|---|
| 1 | Docker basics | Q1, Q2, Q3 | Container vs VM, Dockerfile |
| 2 | Dockerfile instructions | Q4, Q5 | RUN/COPY/ADD, CMD vs ENTRYPOINT |
| 3 | Multi-stage & Compose | Q6, Q7 | Small images, multi-container development |
| 4 | K8s basics | Q8, Q9, Q10 | Orchestrator, Pod, Node |
| 5 | Service & Config | Q11, Q16 | Stable address, ConfigMap vs Secret |
Middle Level (weeks 3-4)
| Step | Topic | Files | Goal |
|---|---|---|---|
| 1 | Service types | Q12 | ClusterIP, NodePort, LoadBalancer |
| 2 | ReplicaSet & Deployment | Q13 | Desired state, self-healing |
| 3 | Health checks | Q17, Q18, Q19 | Liveness, readiness, startup |
| 4 | Ingress & Namespace | Q20, Q21 | L7 routing, logical isolation |
| 5 | Rolling update | Q22 | Zero-downtime deploy |
Senior Level (weeks 5-6)
| Step | Topic | Files | Goal |
|---|---|---|---|
| 1 | HPA deep dive | Q15 | Formula, stabilizationWindow, custom metrics |
| 2 | StatefulSet | Q23 | Stable identity, ordered updates, headless service |
| 3 | Monitoring | Q24 | Prometheus, Grafana, ELK, distributed tracing |
| 4 | Scaling strategies | Q14, Q15, Q22 | HPA + VPA + Cluster Autoscaler |
Key Topic Connections
Docker Topic
Q1 (Containerization) → Q2 (Container vs VM) → Q3 (Dockerfile)
↓
Q4 (Instructions) → Q5 (CMD vs ENTRYPOINT) → Q6 (Multi-stage) → Q7 (Compose)
K8s Basics Topic
Q8 (K8s overview) → Q9 (Pod) → Q10 (Node) → Q13 (ReplicaSet)
Key connections:
- Q9 <-> Q13: Pods are managed through ReplicaSet (which is created by Deployment)
- Q10 <-> Q9: Node is the server where Pods run
Network Topic
Q11 (Service) → Q12 (Service Types) → Q20 (Ingress)
Key connections:
- Q11 <-> Q12: Service is the abstraction, types are concrete implementations
- Q12 <-> Q20: LoadBalancer (L4) vs Ingress (L7) — different layers
Configuration & Health Topic
Q16 (ConfigMap/Secret) → Q17 (Liveness) → Q18 (Readiness) → Q19 (Health checks)
Scaling Topic
Q14 (Scaling) → Q15 (HPA) → Q22 (Rolling update)
Cheat Sheet: What to Know for Each Level
Junior
- Container = Linux process, VM = full OS
- Dockerfile: FROM, RUN, COPY, CMD, ENTRYPOINT
- CMD can be overridden at runtime, ENTRYPOINT — no (but you can add args)
- Pod = smallest unit in K8s, usually 1 container
- Service = stable address for a group of Pods
- ConfigMap = configs, Secret = secrets (base64, NOT encryption!)
Middle
- Multi-stage build: only the last FROM ends up in the final image
- ReplicaSet is created by Deployment, not used directly
- Liveness probe → restart, Readiness probe → remove from load balancing
- ClusterIP (internal), NodePort (port on Node), LoadBalancer (cloud LB)
- Ingress = L7 router, requires Ingress Controller
- Rolling update: maxUnavailable + maxSurge control the process
Senior
- HPA formula: desiredReplicas = ceil(current * (currentMetric / desiredMetric))
- stabilizationWindow prevents flapping
- StatefulSet: stable identity (web-0, web-1), ordered updates, headless service
- Secrets in etcd without EncryptionConfiguration = plaintext
- Prometheus: pull-model, local storage 15-30 days, Thanos for long-term
- Gateway API (GA v1.28) gradually replaces Ingress
File Format
Each file contains:
- Junior Level — basic understanding, simple analogies, examples
- Middle Level — internals, typical mistakes, practical examples
- Senior Level — deep dive, edge cases, production experience, monitoring
- Interview Cheat Sheet — key points, frequent questions, red flags, related topics