Interview Q&A / Docker & Kubernetes
Docker & Kubernetes interview questions
Images, containers, Dockerfiles, pods and deployments, from first principles.
Prefer rapid revision? Practise Docker & Kubernetes short interview answers →
- What is Docker Compose and when would you use it?
Docker Compose lets you define a multi-container app, such as a web server, database and cache, in one YAML file and start or stop all of it with one command. It sets up a shared network so services reach each other by name, and it is mainly used for local development, testing and small single-server deployments.
BeginnerIn-depth3 min read - What is the difference between a container and a virtual machine?
A virtual machine runs a full guest operating system on virtual hardware provided by a hypervisor. A container is just an isolated process that shares the host's kernel, so it starts in seconds or less, uses far less memory, and is lighter to ship, but gives weaker isolation than a VM.
BeginnerIn-depth4 min read - What is the difference between a Docker image and a container?
An image is a read-only template that holds your app, its dependencies and a startup command. A container is a running (or stopped) instance of that image, with its own thin writable layer on top. One image can start many containers.
BeginnerIn-depth3 min read - Why is data in a container temporary, and what are Docker volumes and bind mounts?
Files a container writes go into its own writable layer, which is deleted when the container is removed. To keep data, you mount storage from outside the container. A volume is storage managed by Docker; a bind mount maps a specific folder from the host into the container.
BeginnerIn-depth3 min read - What is the difference between a Pod, a Deployment and a Service in Kubernetes?
A Pod is the smallest unit Kubernetes runs, one or more containers sharing an IP address. A Deployment keeps a chosen number of identical Pods running and handles rolling updates. A Service gives those changing Pods one stable name and IP and load-balances traffic across them.
IntermediateIn-depth4 min read - What is the difference between CMD and ENTRYPOINT in a Dockerfile?
ENTRYPOINT sets the program the container always runs, and CMD sets default arguments or a default command that is easy to override. Arguments passed to docker run replace CMD but are appended to ENTRYPOINT; changing ENTRYPOINT needs the --entrypoint flag.
IntermediateIn-depth3 min read - What is the difference between liveness, readiness and startup probes in Kubernetes?
A liveness probe asks "is this container stuck?" and Kubernetes restarts it if the probe keeps failing. A readiness probe asks "can it take traffic right now?" and a failing Pod is removed from Service load balancing without a restart. A startup probe gives slow-starting apps time to boot before the other probes begin.
AdvancedIn-depth4 min read