DevOps Interview Questions: Docker, K8s, CI/CD
As software engineering roles increasingly demand proficiency in cloud-native infrastructure, preparing for DevOps and Site Reliability Engineering (SRE) interviews requires deep technical understanding beyond basic theoretical definitions. Interviewers frequently probe into real-world troubleshooting scenarios, architectural trade-offs, and practical configuration patterns.
This comprehensive guide compiles the most critical interview questions and expert answers across three foundational pillars: Docker containerization, Kubernetes orchestration, and CI/CD pipelines.
1. Docker Interview Questions
### Q: What is the difference between CMD and ENTRYPOINT in a Dockerfile?
Answer: Both instructions define what command executes when a container starts, but they behave differently regarding arguments and overrides:
- CMD provides default arguments for an execution container. It can be easily overridden by passing command-line arguments when running
docker run <image> <new_command>. - ENTRYPOINT configures a container that will run as an executable. Arguments passed via
docker runare appended as parameters to the entrypoint executable rather than overriding it.
### Q: How do you optimize Docker image sizes for production?
- Use multi-stage builds to separate compilation tools from the final runtime environment.
- Choose lightweight base images like Alpine Linux or distroless images instead of full OS images (e.g., Ubuntu).
- Combine RUN commands and leverage the Docker layer cache effectively by copying
package.jsonbefore application source code.
2. Kubernetes (K8s) Interview Questions
### Q: What is the difference between a Deployment and a StatefulSet in Kubernetes?
Answer:
- Deployments manage stateless applications where pods are interchangeable, ephemeral, and scale horizontally behind a load balancer with random pod naming suffixes.
- StatefulSets manage stateful applications (like databases) requiring persistent storage, unique network identifiers (e.g.,
pod-0,pod-1), and ordered, graceful deployment and scaling.
### Q: Explain how Kubernetes Liveness, Readiness, and Startup probes work.
- Startup Probe: Checks if the application within the container has started. If it fails, the container is killed and restarted, protecting slow-starting containers.
- Liveness Probe: Determines when to restart a container (e.g., if a deadlock occurs). If liveness fails, Kubernetes kills the pod.
- Readiness Probe: Determines whether a container is ready to accept incoming network traffic. If readiness fails, the pod's IP is removed from service endpoints.
3. CI/CD & Automation Interview Questions
### Q: What is the difference between Continuous Integration (CI), Continuous Delivery (CD), and Continuous Deployment (CD)?
- Continuous Integration (CI): Developers frequently merge code changes into a central repository where automated builds and tests run automatically.
- Continuous Delivery (CD): Automatically builds and validates code packages, preparing them for release, but requiring manual human approval before pushing to production.
- Continuous Deployment (CD): Automatically pushes every code change that passes all automated test stages directly into production without manual intervention.
Conclusion
Mastering these core DevOps interview concepts—ranging from Docker multi-stage builds and Kubernetes pod lifecycle probes to automated CI/CD release strategies—will equip engineers to excel in technical evaluations and build resilient production infrastructures.