Docker and Kubernetes Interview Questions

Dan Lee's profile image
Dan LeeData & AI Lead
Last update
Docker and Kubernetes Interview Questions

Docker and Kubernetes interviews for SRE, platform, backend and MLOps roles rarely ask you to recite object definitions. You get a situation: an image that takes four minutes to build, a pod that is OOMKilled below its limit on the dashboard, a rollout that throws 502s, a drain that never finishes. Then you explain the mechanism and the change you would make.

Candidates slip on a small set of details. Requests are for scheduling while limits are enforced by the kernel. A shell as PID 1 swallows SIGTERM. A liveness probe that checks the database restarts the whole fleet during a database blip. Endpoint removal races the shutdown signal. Each of these takes two sentences to explain once you have watched it fail, and a lot longer to debug if you have not.

This page has 31 practice questions in five areas: containers and Dockerfiles, core Kubernetes objects, scheduling and resources, probes and rollouts, and debugging, networking and scaling. Answers use current behavior (Kubernetes 1.35 to 1.37 and BuildKit-based Docker builds) and include the manifests and commands you would actually run.

Intermediate31 questions

Docker and Kubernetes Interview Questions

Practice Docker and Kubernetes interview questions on images, Dockerfiles, PID 1, pods, Services, resources, probes, rollouts, networking and debugging, with worked answers.

Site Reliability EngineerPlatform EngineerDevOps EngineerBackend EngineerMLOps EngineerMachine Learning Engineer

Containers, Images and Dockerfiles

Most Kubernetes trouble starts one layer down, in the image and the process inside it. Interviewers open here because it shows whether you know what a container actually is: a process with namespaces, cgroups and a layered filesystem, not a small virtual machine.

The idea that matters most is that images are immutable and built in layers. It explains slow builds, leaked secrets, huge images, edits that vanish on restart and, through PID 1, why a container can ignore a polite request to stop.

Containers, Images and Dockerfiles

A teammate hot-fixed a config file with kubectl exec inside a running pod. After the container restarted, the fix was gone, and the other two replicas never had it. Explain what an image and a container are, and why the change did not survive.

EasyContainers, Images and Dockerfiles

Sample Answer

An image is a read-only stack of layers plus a config (entrypoint, environment, user), identified by a content digest. A container is one running instance of it: the runtime stacks the image layers with overlayfs, adds a thin writable layer on top, and starts the process in its own namespaces and cgroup. The exec edit landed in that one container's writable layer. When the kubelet restarts a container it creates a new one from the same image, with a fresh writable layer, so the edit disappears. The other replicas were separate containers and never saw it. The trap is treating a container like a server you patch in place. Change config through a ConfigMap or a new image, and keep data that must persist in a volume.

Bash
1docker run -d --name web nginx:1.29
2docker exec web sh -c 'echo "# hotfix" > /etc/nginx/conf.d/hotfix.conf'
3docker diff web                 # A /etc/nginx/conf.d/hotfix.conf: only in the writable layer
4docker rm -f web && docker run -d --name web nginx:1.29
5docker exec web ls /etc/nginx/conf.d   # hotfix.conf is gone: new container, new layer
Learn this in the Site Reliability Engineering Interview course

Kubernetes Core Objects

Questions on Pods, Deployments, Services and their relatives check whether you can pick the right object and predict what its controller will do. A wrong pick, such as a Deployment for a database, works in a demo and fails in production.

Everything here is declarative. You write desired state, and a controller keeps reconciling the cluster toward it. Once you think in owners and selectors (Deployment to ReplicaSet to Pod, Service to EndpointSlice), most behavior that looks odd becomes predictable.

Kubernetes Core Objects

You delete a misbehaving pod and an identical one appears seconds later with a new name. Walk through the objects that made that happen, and say what you change to roll out a new image.

EasyKubernetes Core Objects

Sample Answer

A Deployment owns ReplicaSets, and each ReplicaSet owns pods. The Deployment controller creates one ReplicaSet per version of the pod template, labelled with a pod-template-hash. The ReplicaSet controller keeps the number of matching pods equal to replicas. Deleting a pod drops the count below replicas, so the ReplicaSet creates a replacement with a new random suffix. To ship a new image, change the Deployment's pod template (kubectl set image or apply an edited manifest). That creates a new ReplicaSet, and the controller scales it up while scaling the old one down. Old ReplicaSets stay at zero replicas for rollback, 10 by default (revisionHistoryLimit). The trap is editing pods directly: the change is lost when the pod is replaced. A bare Pod with no controller is not recreated at all.

Bash
1kubectl get deploy,rs,pods -l app=api
2kubectl get pod api-7d9c8b6f4-x2kq9 -o jsonpath='{.metadata.ownerReferences[0].kind}'   # ReplicaSet
3kubectl set image deployment/api api=registry.example.com/api:1.8.3
4kubectl rollout status deployment/api
Learn this in the Site Reliability Engineering Interview course

Scheduling and Resources

Resource questions separate people who have run Kubernetes in production from people who have read about it. Expect throttled latency, OOMKilled pods with memory to spare on the dashboard, Pending pods on half-empty nodes and drains that never finish.

Keep two mechanisms apart. Requests are bookkeeping for the scheduler and never enforced at runtime, while limits are enforced by the kernel through cgroups. The CPU limit throttles and the memory limit kills, and that one sentence answers a surprising number of questions.

Scheduling and Resources

A container requests 250m CPU and 256Mi of memory, with limits of 1 CPU and 512Mi. What does each number do, and what happens when the container goes over each one?

EasyScheduling and Resources

Sample Answer

Requests drive scheduling. The scheduler places the pod only where allocatable resources, minus the requests of pods already there, fit 250m and 256Mi. Actual usage is ignored. The CPU request also sets the container's share of contended CPU. Limits are enforced by the kernel through cgroups. Above 1 CPU the container is throttled, never killed. Above 512Mi the cgroup OOM killer ends it: OOMKilled, exit code 137, then a restart under the pod's restartPolicy. Using memory between the request and the limit is allowed, but under node memory pressure a pod above its request is among the first eviction candidates. If you set only a limit, Kubernetes copies it into the request. Since 1.35, in-place resize is GA, so both can change without recreating the pod.

Text
1containers:
2- name: api
3  image: registry.example.com/api:1.8.3
4  resources:
5    requests: {cpu: 250m, memory: 256Mi}   # scheduling and CPU weight
6    limits: {cpu: "1", memory: 512Mi}      # throttled above 1 CPU, OOMKilled above 512Mi
Learn this in the Site Reliability Engineering Interview course

Health Checks, Rollouts and Shutdown

Most outages follow a change, so interviewers spend time on how a new version reaches production and how an old pod leaves it. Probes, rolling update parameters and graceful termination decide whether a deploy is invisible to users or a burst of errors.

The key idea is that each probe answers a different question and triggers a different action. Readiness controls traffic, liveness controls restarts, and startup protects slow boots. Mixing them up turns a short dependency blip into a cluster-wide restart.

Health Checks, Rollouts and Shutdown

Explain liveness, readiness and startup probes. For each one, what does Kubernetes do when it fails, and what are the default timings?

EasyHealth Checks, Rollouts and Shutdown

Sample Answer

A failing readiness probe sets the pod's Ready condition to false, so it leaves Service endpoints and gets no new traffic. The container keeps running. A failing liveness probe, after failureThreshold consecutive failures, makes the kubelet kill the container (honouring the grace period) and restart it under the restart policy. A startup probe runs first. Until it succeeds, liveness and readiness probes are not run. If it fails failureThreshold times, the container is restarted. Defaults: periodSeconds 10, timeoutSeconds 1, failureThreshold 3, successThreshold 1 (it must be 1 for liveness and startup), initialDelaySeconds 0. So a default liveness probe restarts a hung container after about 30 seconds. An httpGet probe passes on any status from 200 to 399. With no readiness probe, a container counts as ready once it starts.

Learn this in the Site Reliability Engineering Interview course

Debugging, Networking and Scaling

Live debugging rounds hand you a broken pod or a status column and ask for the next command. Strong answers read kubectl describe, events and exit codes before guessing, then move outward to Services, DNS, NetworkPolicy and autoscaling.

One habit covers most of these questions: find the controller or component that made the decision, and read its reason. The scheduler explains Pending, the kubelet explains restarts and pulls, EndpointSlices explain routing, and the HPA status explains scaling.

Debugging, Networking and Scaling

A pod shows CrashLoopBackOff with 14 restarts. Walk through how you find the cause.

EasyDebugging, Networking and Scaling

Sample Answer

CrashLoopBackOff is a symptom: the container keeps exiting, and the kubelet restarts it with backoff of 10 s, 20 s, 40 s and so on, capped at 300 s, reset after 10 minutes of clean running. Start with kubectl describe pod: Last State shows the reason and exit code, and Events show probe failures and kills. Exit code 1 is an app error, 137 is SIGKILL (often OOMKilled, or a liveness kill after the grace period), 143 is SIGTERM, 127 is a command not found, and exec format error usually means an image built for the wrong CPU architecture. Then kubectl logs --previous, because the current container may have just started and logged nothing. Usual causes: missing config, a dependency unreachable at startup, or liveness killing a slow start.

Bash
kubectl describe pod api-7d9c8b6f4-x2kq9 | sed -n '/Last State/,/Restart Count/p'
kubectl logs api-7d9c8b6f4-x2kq9 --previous --tail=50
kubectl get events --field-selector involvedObject.name=api-7d9c8b6f4-x2kq9 --sort-by=.lastTimestamp
Learn this in the Site Reliability Engineering Interview course

How to Prepare for Docker and Kubernetes Interviews

Reproduce the Linux behavior under the container

Most hard container questions are Linux questions in disguise: PID 1 and signals, cgroup memory limits, CPU quotas and throttling. Run a container locally, send it docker stop, push it past its memory limit and read cpu.stat while it is throttled. Processes and signals, Memory: virtual memory, page cache, OOM and cgroups and CPU and load do this on a real Linux sandbox.

Practice reading kubectl output cold

Interviewers paste a kubectl describe block, an event line or a status column and ask what is wrong. Practice naming the field you rely on (Last State, exit code, FailedScheduling reason) and the next command. Use a local cluster such as kind and break things on purpose. The troubleshooting round teaches a method to narrate, and Lab: latency spike after a deploy lets you practice it.

Know the rollout numbers and the rollback path

Be able to compute what maxSurge and maxUnavailable allow for a given replica count, explain what readiness gates, and say what a rollback restores and what it leaves behind. Pair the mechanics with when to stop a rollout. Safe changes: canaries, progressive rollout, flags and rollback and Shadow, canary and blue-green cover both.

Treat images as versioned artifacts

Pin base images by digest, deploy by digest or an immutable tag, and be able to trace a running pod back to the exact build. This matters even more for ML services, where the image carries the model and its library versions. Packaging a model and Reproducibility and versioning show how digests and versions tie a production decision to specific bytes.

Trace a request from DNS to the pod

Networking questions reward a clear path: the client resolves a name through CoreDNS, kube-proxy rules translate the Service IP to a pod, NetworkPolicy allows or drops the packet, and the app answers. Practice drawing that path and naming where each failure shows up. DNS and load balancing and Network troubleshooting from tool output cover the parts that apply outside Kubernetes too.

How Ready Are You for Docker and Kubernetes Interviews?

1 / 6
Containers

Pods always take the full 30-second grace period to stop and exit with code 137. The Dockerfile uses CMD python app.py. What is the most likely cause?

Frequently Asked Questions

What Docker and Kubernetes topics come up most in interviews?

Expect images and Dockerfiles (layers, caching, multi-stage builds, non-root users), PID 1 and graceful shutdown, Deployments, Services and StatefulSets, requests and limits, probes, rolling updates, and debugging pods that crash, fail to pull or stay Pending. Platform and SRE roles add NetworkPolicy, DNS, autoscaling and disruption budgets. Most questions arrive as a symptom or a block of kubectl output, so practice explaining the mechanism, not just naming the object.

Do I need the CKA certification to pass a Kubernetes interview?

No. Interviewers care whether you can reason about a broken cluster, not whether you hold a certificate. The CKA syllabus is still useful practice because it is hands-on and timed, and it covers kubectl fluency, scheduling, networking and troubleshooting. If you already run Kubernetes at work, spend the time reproducing failures in a local cluster and explaining them out loud instead.

Is Docker still relevant now that Kubernetes uses containerd?

Yes. Kubernetes removed dockershim in 1.24, so nodes run containerd or CRI-O, but the images are standard OCI images and most teams still build them with Docker and BuildKit. Interviews ask about Dockerfiles, layers and image size because that is where build time, security and startup time are decided. Runtime questions shift to crictl and the kubelet, while build questions stay with Docker.

How much Kubernetes do ML and data engineers need for interviews?

Less than SRE and platform engineers, but more than a definition of a pod. MLOps and ML engineering loops ask how you package a model in an image, set requests and limits for CPU or GPU serving, roll out a new model with a canary, run batch jobs and scale inference on traffic. Data engineers usually meet Jobs, CronJobs, resource limits and OOMKilled Spark or Python pods.

How long does it take to prepare for a Docker and Kubernetes interview?

If you run Kubernetes at work, two to three weeks of focused practice is usually enough: one area from this page every few days, plus reproducing each failure in a local cluster. Coming mostly from application development, plan four to six weeks. Fluency with kubectl describe, events and logs takes repetition on a real cluster, and reading about it does not build that speed.

Which Kubernetes version should I study for interviews in 2026?

Study current behavior, Kubernetes 1.35 to 1.37 as of late 2026, but focus on stable concepts, since most questions do not depend on a release. Know a few recent changes: native sidecar containers (GA in 1.33), the preStop sleep action (GA in 1.34), in-place pod resize (GA in 1.35), cgroup v1 deprecation in 1.35, and Gateway API replacing a frozen Ingress API.

Dan Lee's profile image

Written by

Dan Lee

Data & AI Lead

Dan is a seasoned data scientist and ML coach with 10+ years of experience at Google, PayPal, and startups. He has helped candidates land top-paying roles and offers personalized guidance to accelerate your data career.

Connect on LinkedIn