DevOps & Containers12 lessons15 quiz questions
Kubernetes & Docker
Master Kubernetes & Docker for software engineering interviews.
What You Will Learn
- ✓Docker Fundamentals — Images, Containers, and Dockerfiles
- ✓Docker Networking & Volumes — Persistence and Communication
- ✓Docker Compose — Multi-Container Application Orchestration
- ✓Kubernetes Architecture — Control Plane and Node Components
- ✓Pods, ReplicaSets & Deployments — Running Workloads
- ✓Services, Ingress & Networking — Exposing Applications
- ✓ConfigMaps, Secrets & Environment Variables
- ✓Persistent Storage: PVs, PVCs, StorageClasses & StatefulSets
- ✓Helm Charts: Package Management for Kubernetes
- ✓Monitoring & Debugging Kubernetes Clusters
- ✓Kubernetes Security: RBAC, Network Policies & Pod Security
- ✓Production Operations: Autoscaling, Deployments & Disaster Recovery
Overview
Master Kubernetes & Docker for software engineering interviews.
Docker Fundamentals
Docker is a containerization platform that packages applications and their dependencies into isolated, portable units called containers. Unlike virtual machines, containers share the host kernel — making them lightweight, fast to start, and efficient.
Core Concepts
Image: An immutable, layered read-only template. Think of it as a class definition.
Container: A running instance of an image. Think of it as an object instantiated from a class.
Layer: Each instruction in a Dockerfile creates a new read-only layer. Layers are cached and shared between images.
Registry: A storage and distribution system for images. Docker Hub is the public default; AWS ECR, GCR, and GHCR are popular private options.
Your First Dockerfile — Node.js API
Multi-Stage Build — Production Best Practice
Multi-stage builds let you use a fat builder image to compile/bundle, then copy only the artifacts into a slim runtime image. This dramatically reduces final image size.
Result: A 1.2 GB builder image becomes a 180 MB production image. The build tools, source maps, TypeScript compiler, and dev dependencies are all discarded.
Dockerfile Instructions Reference
Purpose
Base image
Set working directory
Copy files from host
Like COPY can extract tarballs
Execute command in new layer
Set environment variable
Build-time variable
Document network port
Set running user
Default command (overridable)
Fixed entry point
Container health probe
Declare mount point
Python Example — FastAPI Application
Layer Caching — The Golden Rule
Docker processes Dockerfile instructions top-to-bottom. When a layer changes, all subsequent layers are invalidated. The strategy is: least-frequently-changing instructions first.
The .dockerignore File
Always create to prevent bloating the build context:
Essential Docker CLI Commands
Interview Talking Points
"I always use multi-stage builds in production to minimize image size and attack surface."
"Layer caching is the biggest Dockerfile performance lever — I order instructions from least to most frequently changing."
"I run containers as non-root and use HEALTHCHECK so orchestrators know if the app is actually ready."
"The difference between CMD and ENTRYPOINT: CMD can be overridden at runtime, ENTRYPOINT cannot. I use ENTRYPOINT for the binary and CMD for default arguments."
Java Implementation
Python Implementation
Sample Quiz Questions
1. What is the key difference between a Docker image and a Docker container?
Remember·Difficulty: 1/5
2. In a Dockerfile, why should you COPY package.json and run npm install BEFORE copying the rest of the source code?
Understand·Difficulty: 2/5
3. Which Docker networking mode allows a container to share the host machine's network stack directly, without NAT?
Remember·Difficulty: 2/5
+ 12 more questions available in the full app.
Related Topics
Master Kubernetes & Docker for Your Next Interview
Get access to full lessons, adaptive quizzes, cheat sheets, code playground, and progress tracking — completely free.