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
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
2dockerexec web sh -c 'echo "# hotfix" > /etc/nginx/conf.d/hotfix.conf'3dockerdiff web # A /etc/nginx/conf.d/hotfix.conf: only in the writable layer4dockerrm -f web &&docker run -d --name web nginx:1.29
5dockerexec web ls /etc/nginx/conf.d # hotfix.conf is gone: new container, new layer
An interviewer says "a container is just a lightweight VM." Correct the statement: which kernel features make a container, and what production surprises come from the difference?
MediumContainers, Images and Dockerfiles
Sample Answer
A container is an ordinary Linux process tree with a restricted view and a budget. Namespaces give the view: separate PID, network, mount, UTS, IPC, user, cgroup and time namespaces. cgroups give the budget: CPU, memory, PIDs and I/O are limited and accounted per group. Capabilities and seccomp trim what it may ask the kernel to do. There is no guest kernel: every container on the node shares the host's.
Two surprises follow. free, /proc/meminfo and os.cpu_count() describe the host, not the limit, so a runtime that sizes its heap or thread pool from them overshoots and gets OOMKilled or throttled; the real limits are in /sys/fs/cgroup. And isolation is only as strong as the shared kernel: a kernel bug or a privileged container can reach the host.
Bash
1# inside a container with a 512Mi memory limit and a 2-CPU limit (cgroup v2)2free -m |head -2 # host memory, not the limit3cat /sys/fs/cgroup/memory.max # 5368709124cat /sys/fs/cgroup/cpu.max # 200000 100000: 2 CPUs of time per 100 ms period5ls -l /proc/self/ns # the namespaces this process belongs to
Every commit to a Python service triggers a four-minute pip install in CI, even when requirements.txt did not change. The Dockerfile copies the whole repo with COPY . . and then runs pip install -r requirements.txt. Fix it and explain the cache rules you rely on.
MediumContainers, Images and Dockerfiles
Sample Answer
Each instruction produces a layer, and BuildKit (Docker's default builder) reuses a cached layer only if that instruction and everything before it are unchanged. For COPY and ADD it compares a checksum of the copied files' contents and metadata (mtime is ignored). For RUN it compares only the command string.
With COPY . . first, any source edit changes the checksum, so every later step reruns, including the install. Order instructions from least to most frequently changed: base image, dependency manifest, install, then source. A cache mount keeps pip's download cache across builds even when the install layer must rebuild.
Two traps: a lone RUN apt-get update is cached forever because its string never changes, and ephemeral CI runners need a registry cache to reuse anything.
A Go service image is 1.2 GB, the build context upload takes 40 seconds, and a scanner found an .env file and an SSH key inside the image even though a later RUN rm deletes them. Fix all three.
MediumContainers, Images and Dockerfiles
Sample Answer
Context: docker build sends the directory to the builder, minus anything matched by .dockerignore. Without one you ship .git, data files and secrets. Add .git, .env, *.pem and build outputs to it.
The leak: layers are additive. RUN rm in a later layer only records a deletion marker; the file is still in the earlier layer for anyone who pulls the image. Never COPY secrets. Pass build-time secrets with RUN --mount=type=secret; they are never written to a layer. Rotate the leaked key.
The size: use a multi-stage build. Compile in a full Go toolchain stage and copy only the static binary into a minimal runtime image. BuildKit builds only the stages the final target depends on.
Text
1# syntax=docker/dockerfile:1
2FROM golang:1.26 AS build
3WORKDIR /src
4COPY go.mod go.sum ./
5RUN go mod download
6COPY . .
7RUN CGO_ENABLED=0 go build -o /out/api ./cmd/api
89FROM gcr.io/distroless/static-debian12:nonroot
10COPY --from=build /out/api /api
11ENTRYPOINT ["/api"]
Pods of a Python worker always take the full 30 seconds to terminate, end with exit code 137, and lose in-flight jobs. The Dockerfile ends with ENTRYPOINT /docker-entrypoint.sh, and the script runs migrations and then python worker.py. Explain and fix it.
HardContainers, Images and Dockerfiles
Sample Answer
Shell form runs /bin/sh -c /docker-entrypoint.sh, so a shell is PID 1 and Python is its child. On pod deletion, SIGTERM goes to process 1 only. The kernel treats PID 1 of a namespace as init: a signal with no installed handler is dropped, and only SIGKILL and SIGSTOP from the parent namespace get through by force. The shell neither handles nor forwards SIGTERM, and after terminationGracePeriodSeconds (30 s by default) the runtime sends SIGKILL: exit code 128 + 9 = 137.
Use exec form, and exec the last command so Python replaces the shell as PID 1. The worker must install its own SIGTERM handler, because an unhandled SIGTERM to PID 1 is still dropped. If it spawns children, add tini to forward signals and reap zombies.
A security review flags your Dockerfile: it starts FROM python:3.13 and never sets USER. You add runAsNonRoot: true to the pod, and the container now fails with CreateContainerConfigError. Harden the image and explain the error.
MediumContainers, Images and Dockerfiles
Sample Answer
Pin the base image. A tag like 3.13 is mutable and moves with every patch release, so two builds a week apart can differ. FROM python:3.13-slim@sha256:... keeps the readable tag but resolves to one immutable image; let a dependency bot bump the digest.
Run as a fixed numeric UID. With runAsNonRoot: true, the kubelet validates at start that the container will not run as UID 0. An image with no USER runs as root, so it is rejected. A named user (USER app) also fails, because the kubelet cannot check a name and reports that the image has a non-numeric user. Use USER 10001 or set runAsUser in the pod.
Then set allowPrivilegeEscalation: false, drop all capabilities, and use readOnlyRootFilesystem: true with an emptyDir for scratch.
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}'# ReplicaSet3kubectl set image deployment/api api=registry.example.com/api:1.8.3
4kubectl rollout status deployment/api
A new ClusterIP Service times out, although its pods are Running and pass their probes. Explain how a Service routes traffic to pods, what each Service type adds, and the order in which you check things.
MediumKubernetes Core Objects
Sample Answer
A Service is a stable virtual IP and DNS name. The EndpointSlice controller lists the IPs of Ready pods whose labels match its selector. kube-proxy on each node (iptables or nftables mode; IPVS is deprecated since 1.35) rewrites traffic for the ClusterIP to one of those endpoints. Nothing listens on the ClusterIP itself.
Check in order. An empty EndpointSlice means a selector and label mismatch, or pods not Ready. Does targetPort match the port the container listens on, and is the app bound to 0.0.0.0 rather than 127.0.0.1? Then look at NetworkPolicy.
Types: ClusterIP is internal, NodePort adds a port (30000 to 32767) on every node, LoadBalancer adds a cloud load balancer, and ExternalName is a DNS CNAME. A headless Service (clusterIP: None) returns pod IPs directly.
Bash
1kubectl get endpointslices -l kubernetes.io/service-name=api
2kubectl get svc api -o jsonpath='{.spec.selector}{"\n"}{.spec.ports}{"\n"}'3kubectl get pods -l app=api -o wide --show-labels
4kubectl run tmp --rm -it --image=busybox:1.37 --restart=Never -- wget -qO- api:8080/healthz
You are setting up HTTP routing for a new cluster this year. Do you use Ingress or Gateway API, and how would you send 10% of traffic to a new version of a service?
MediumKubernetes Core Objects
Sample Answer
Gateway API. Ingress is still GA but frozen: no new features, and the docs recommend Gateway. Ingress NGINX, the most widely used controller, was retired in March 2026 and no longer gets security fixes. Ingress only expresses hosts and paths, so canary weights and header matching live in controller-specific annotations that do not port.
Gateway API splits the roles. A GatewayClass is the implementation, a Gateway is the listener the platform team owns, and app teams attach HTTPRoutes from their own namespaces. Weighted backendRefs and header matches are in the spec.
Two traps: Gateway API ships as CRDs outside the Kubernetes release, so install the version your controller supports; and a route in another namespace only attaches if the Gateway listener's allowedRoutes permits it.
Security rotated a database password stored in a Secret. An hour later, some pods still use the old password, and a teammate argues that it does not matter much because Secrets are encrypted anyway. What is going on?
MediumKubernetes Core Objects
Sample Answer
It depends on how the pod reads the Secret. Environment variables (secretKeyRef, envFrom) are resolved once when the container starts and never change. Files from a Secret volume are refreshed by the kubelet eventually, after its sync period and cache delay, unless the volume is mounted with subPath, which never updates. The app must also re-read the file. Pods that restarted got the new value.
For env-var consumers, trigger a rollout: kubectl rollout restart, or put a checksum of the Secret in a pod template annotation so every change creates a new revision.
The teammate is wrong. Secret data is base64-encoded, not encrypted, and is stored unencrypted in etcd unless the cluster enables encryption at rest. Anyone who can create a pod in the namespace can read its Secrets.
Bash
kubectl get secret db -o jsonpath='{.data.password}'| base64 -d # encoding, not encryptionkubectl rollout restart deployment/api # env vars are only read at container startkubectl rollout status deployment/api
A team runs a three-broker message queue as a Deployment that mounts one PersistentVolumeClaim. Two pods are stuck in ContainerCreating with Multi-Attach error, and brokers come back with new names after restarts. Redesign it.
HardKubernetes Core Objects
Sample Answer
Deployment pods are interchangeable: random names, one template, so all three reference the same claim. A ReadWriteOnce volume attaches to one node at a time, hence the Multi-Attach errors.
A StatefulSet fits. Each replica gets a stable ordinal name (broker-0), a stable DNS name through a headless Service (broker-0.broker.ns.svc.cluster.local), and its own claim from volumeClaimTemplates (data-broker-0) that follows it across rescheduling. Pods start in order by default, and rolling updates go from the highest ordinal down, one at a time, waiting for Ready.
Traps: scaling down or deleting the StatefulSet keeps the PVCs unless persistentVolumeClaimRetentionPolicy says Delete; deleting it does not guarantee orderly pod shutdown, so scale to 0 first; and the StatefulSet gives identity, not replication. The application still handles data copies and failover.
A nightly export Job fails on a bad config file, retries for a long time, and leaves seven failed pods behind. Another night a node drain killed it, and that counted as a failure too. Configure the Job properly.
MediumKubernetes Core Objects
Sample Answer
A Job runs pods until enough of them succeed. backoffLimit defaults to 6 retries, and failed pods are recreated with exponential backoff (10 s, 20 s, 40 s and so on, capped at ten minutes), which is where the seven pods and the long tail came from.
A config error will never succeed, so retrying is waste. podFailurePolicy classifies failures: FailJob on the exit code your app uses for bad config ends the Job at once, and Ignore on the DisruptionTarget condition means preemption, eviction or a drain does not count against backoffLimit. It requires restartPolicy: Never.
Add activeDeadlineSeconds as a hard cap on total runtime and ttlSecondsAfterFinished so finished Jobs and their pods are cleaned up. From a CronJob, add concurrencyPolicy: Forbid so runs never overlap.
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.
A node runs short of memory. It hosts a pod whose requests equal its limits, a pod with requests but higher limits, and a batch pod with no resources set. Which one goes first, and how do you protect a critical service?
MediumScheduling and Resources
Sample Answer
Kubernetes assigns a QoS class from the resources. Guaranteed: every container has CPU and memory requests equal to limits. BestEffort: none set. Everything else is Burstable.
The kubelet evicts when node memory crosses its threshold. It does not rank by QoS class directly: it first picks pods using more than their requests, ordered by priority and then by how far over they are. A BestEffort pod has a request of zero, so it is always over and usually goes first. If memory runs out before the kubelet acts, the kernel OOM killer decides, using the oom_score_adj the kubelet set: -997 for Guaranteed, 1000 for BestEffort.
To protect a service, make it Guaranteed (every container, sidecars included), give it a PriorityClass, and set honest requests on everything else.
An API pod with limits.cpu: 1 averages 35% CPU, yet p99 latency jumps by up to 90 ms every few seconds. A sibling pod restarts with OOMKilled while the dashboard shows it well below its memory limit. Diagnose both.
HardScheduling and Resources
Sample Answer
The CPU limit becomes a CFS bandwidth quota: cpu.max of 100000 100000, meaning 100 ms of CPU time per 100 ms period. Eight busy threads spend that quota in about 12.5 ms of wall time, then all wait for the next period, adding up to 87 ms to requests in flight. Averages hide it. Confirm with nr_throttled in cpu.stat, size thread pools to the quota (Go 1.25 and later set GOMAXPROCS from it), or raise or drop the limit while keeping the request.
Memory works the other way. The kernel kills the moment the cgroup's charge reaches memory.max, while dashboards sample every 15 to 60 seconds and miss short spikes. The charge also includes tmpfs files, such as a memory-backed emptyDir, which cannot be reclaimed.
Bash
1# inside the throttled container (cgroup v2)2cat /sys/fs/cgroup/cpu.max # 100000 100000 = 1 CPU per 100 ms period3grep -E 'nr_periods|nr_throttled|throttled_usec' /sys/fs/cgroup/cpu.stat
4# for the restarted pod5kubectl get pod worker-0 -o jsonpath='{.status.containerStatuses[0].lastState.terminated.reason}'6kubectl describe pod worker-0 |grep -A4 'Last State'
You add a pool of GPU nodes. Ordinary pods must stay off them, training pods must land only on them, and the log-collector DaemonSet must still run on every node. Configure it.
MediumScheduling and Resources
Sample Answer
Taints repel and tolerations permit, but neither attracts. Taint the GPU nodes (for example nvidia.com/gpu=present:NoSchedule) and label them. Pods without a matching toleration will not schedule there.
Training pods need the toleration and a required node affinity (or nodeSelector) on the label. With only the toleration they may still land on CPU nodes.
The DaemonSet controller adds tolerations for built-in node conditions such as not-ready and unschedulable, but not for your custom taint, so add a toleration with operator: Exists to the log collector.
Know the effects: NoSchedule blocks new pods, PreferNoSchedule is a soft version, and NoExecute also evicts running pods that do not tolerate it (after tolerationSeconds, if set). IgnoredDuringExecution means a later label change does not move running pods.
During a node upgrade, kubectl drain hangs, repeating that it cannot evict a pod because it would violate the pod's disruption budget. What is happening, and what should the budget look like?
MediumScheduling and Resources
Sample Answer
kubectl drain evicts pods through the Eviction API, which checks PodDisruptionBudgets. A budget of minAvailable: 1 on a one-replica Deployment, or maxUnavailable: 0, allows zero voluntary disruptions, so the drain retries forever. It also stalls when the pods are already unhealthy: with the default IfHealthyBudget policy, crash-looping pods use up the budget and cannot be evicted.
Run at least two replicas on different nodes, use maxUnavailable: 1 (or a minAvailable below the replica count), and set unhealthyPodEvictionPolicy: AlwaysAllow so pods that are not Ready can always be evicted.
Know the limits. PDBs only cover voluntary disruptions that go through eviction. Node crashes, OOM kills and a plain kubectl delete pod ignore them, and a Deployment's rolling update uses its own maxUnavailable, not the PDB.
All three replicas of a payments API were scheduled into one zone, and a zone outage took the service down. A teammate then added required pod anti-affinity per zone, and now rollouts hang with a Pending pod. Design the placement.
HardScheduling and Resources
Sample Answer
Built-in spreading is soft: the default constraints are a max skew of 3 per node and 5 per zone, with ScheduleAnyway. Three replicas can share a zone.
Required anti-affinity on topology.kubernetes.io/zone means at most one matching pod per zone. With three zones, the surge pod of a rolling update (25% of 3 rounds up to 1) has nowhere to go, so the rollout hangs.
Use topologySpreadConstraints: maxSkew: 1 on the zone key with DoNotSchedule, so zones differ by at most one pod, plus a softer constraint on hostname. Add matchLabelKeys: [pod-template-hash] so skew is counted per revision and the old ReplicaSet's pods do not block the new one. A zone with no eligible nodes is not counted as a domain; minDomains covers that.
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.
During a two-minute database failover, every pod of an API restarted and the outage lasted ten minutes. The liveness probe calls /health, which runs a query against the database. What went wrong, and how should the probes look?
MediumHealth Checks, Rollouts and Shutdown
Sample Answer
Liveness should answer one question: is this process stuck in a way only a restart fixes? It checked a dependency instead. When the database failed, every pod failed liveness at once, and after three failures (30 seconds) the kubelet restarted them all. Cold caches and a connection storm hit a database that was just recovering, and repeated failures put pods into CrashLoopBackOff, whose delay doubles up to 300 s. The restarts outlasted the outage.
Keep liveness local and cheap: the server responds and its worker loop is not deadlocked. Give it a generous threshold. Be careful tying readiness to a shared dependency too: if every pod goes unready together, the Service has no endpoints, and clients get connection errors instead of a fast error from your app.
Text
1livenessProbe:
2 httpGet: {path: /livez, port: 8080} # in-process only: no database, no downstream calls
3 periodSeconds: 10
4 failureThreshold: 6
5readinessProbe:
6 httpGet: {path: /readyz, port: 8080} # can this pod take traffic right now?
7 periodSeconds: 5
8 failureThreshold: 2
A JVM service needs 90 to 150 seconds to warm up. With a liveness probe at initialDelaySeconds: 60, it gets killed on slow nodes and ends up in CrashLoopBackOff. Fix the probe setup.
MediumHealth Checks, Rollouts and Shutdown
Sample Answer
initialDelaySeconds is a single fixed guess. Too short, and slow starts are killed before they finish, which is what happens here. Too long, and a pod that hangs during boot is not restarted until the delay has passed.
Use a startup probe. Its budget is failureThreshold times periodSeconds: 30 times 10 gives up to 300 seconds, about twice the worst observed start. While it runs, liveness and readiness are held off; after the first success it stops and liveness takes over with tight settings.
Also check why startup is slow. A low CPU limit throttles JIT compilation and class loading, so a pod can start several times slower under a tight limit than it does on a developer laptop.
Text
1startupProbe:
2 httpGet: {path: /livez, port: 8080}
3 periodSeconds: 10
4 failureThreshold: 30 # up to 300 s to start, then liveness takes over
5livenessProbe:
6 httpGet: {path: /livez, port: 8080}
7 periodSeconds: 10
8 failureThreshold: 3
A Deployment has 10 replicas and the default rolling update strategy. During a rollout, how many pods can exist and how many must stay available? The cluster has no spare capacity: what do you change, and what stops a broken version from rolling out everywhere?
MediumHealth Checks, Rollouts and Shutdown
Sample Answer
Both maxSurge and maxUnavailable default to 25%. Surge rounds up, so 2.5 becomes 3 and up to 13 pods can exist. Unavailable rounds down, so 2.5 becomes 2 and at least 8 must be available.
With no headroom, surge pods sit Pending. Set maxSurge: 0 and maxUnavailable: 1 (they cannot both be 0) to replace one pod at a time.
Readiness gates progress: a new pod counts as available only after it has been Ready for minReadySeconds (default 0). A version that never becomes Ready stalls with old pods still serving. After progressDeadlineSeconds (600 by default) the Deployment reports ProgressDeadlineExceeded, but Kubernetes does not roll back by itself; your pipeline has to.
A version that passes readiness but returns errors rolls out fully; that is what canaries catch.
Bash
kubectl patch deployment api -p '{"spec":{"minReadySeconds":20,"strategy":{"rollingUpdate":{"maxSurge":0,"maxUnavailable":1}}}}'kubectl rollout status deployment/api --timeout=10m || kubectl rollout undo deployment/api
A deploy at 14:00 broke checkout. How do you roll back with kubectl, and what will the rollback not undo?
EasyHealth Checks, Rollouts and Shutdown
Sample Answer
kubectl rollout undo deployment/checkout scales the previous ReplicaSet back up and the current one down, using the same rolling strategy. kubectl rollout history lists revisions, and --to-revision picks one. Only changes to the pod template create revisions, and 10 old ReplicaSets are kept by default.
Rollback restores the pod template and nothing else. It does not undo edits to a ConfigMap or Secret the pods read, database migrations, Service or Ingress changes, or other objects shipped in the same release. If the bad change was in a ConfigMap, the old pods come back with the new config.
If a GitOps controller syncs the Deployment from Git, revert the commit as well, or it will reapply the broken version minutes later. Record why each revision exists with the kubernetes.io/change-cause annotation.
Bash
1kubectl rollout history deployment/checkout
2kubectl rollout undo deployment/checkout # previous revision3kubectl rollout undo deployment/checkout --to-revision=41# a specific one4kubectl rollout status deployment/checkout
Every rollout of an HTTP service causes a burst of 502s at the load balancer, even though the app drains in-flight requests on SIGTERM. Explain the race and fix it.
HardHealth Checks, Rollouts and Shutdown
Sample Answer
Pod deletion fans out in parallel. The kubelet runs the preStop hook, then sends SIGTERM. Meanwhile the endpoint is marked terminating in its EndpointSlice, and that change must reach kube-proxy on every node, the ingress or Gateway controller and any cloud load balancer. That takes seconds. An app that closes its listener on SIGTERM gets traffic it can no longer accept: 502s.
Hold shutdown until routing catches up. A preStop sleep (a native hook action, GA since 1.34, so the image needs no shell) pauses for a few seconds first. Then SIGTERM arrives and the app drains and exits.
Size terminationGracePeriodSeconds (default 30) to cover the sleep plus the drain. A preStop still running at the deadline gets a one-off 2-second extension, then SIGKILL.
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=50kubectl get events --field-selector involvedObject.name=api-7d9c8b6f4-x2kq9 --sort-by=.lastTimestamp
A new deploy is stuck with pods in ImagePullBackOff. What are the usual causes, and how do you tell them apart?
EasyDebugging, Networking and Scaling
Sample Answer
The pull failed (ErrImagePull) and the kubelet is retrying with a growing delay, capped at 300 seconds. The Events in kubectl describe pod carry the real error.
not found or manifest unknown means a typo in the name or tag, or the tag was never pushed. unauthorized or pull access denied means missing registry credentials: add imagePullSecrets to the pod or its service account. toomanyrequests is a registry rate limit: mirror images into your own registry. no match for platform in manifest means the image lacks the node's architecture, such as an amd64-only image on an arm64 node.
Also check the pull policy. If you omit it, :latest or no tag means Always, so every pod start depends on the registry; a fixed tag or a digest means IfNotPresent.
Bash
1kubectl describe pod web-5f6d9c7b8-k2l4m |tail -n 15# Events: the actual pull error2kubectl get pod web-5f6d9c7b8-k2l4m -o jsonpath='{.spec.containers[*].image}{"\n"}'3kubectl create secret docker-registry regcred --docker-server=registry.example.com \4 --docker-username=ci-bot --docker-password="$REGISTRY_TOKEN"5kubectl patch serviceaccount default -p '{"imagePullSecrets":[{"name":"regcred"}]}'
A pod has been Pending for 20 minutes. Its event reads 0/6 nodes are available: 2 Insufficient memory, 3 node(s) had untolerated taint {dedicated: gpu}, 1 node(s) didn't match Pod's node affinity/selector. Your dashboard shows those nodes at 40% memory use. Explain it, and name other causes of Pending.
MediumDebugging, Networking and Scaling
Sample Answer
The scheduler compares the pod's requests with each node's allocatable memory minus the requests of pods already placed there. Actual usage does not matter. Two nodes are 40% used but fully requested, because other pods ask for more than they use. Three are tainted for GPU work, and one fails the pod's selector.
Options: right-size inflated requests from observed usage, let the cluster autoscaler add a node, fix the selector, or use priority and preemption. Allocatable is also below capacity, since system reservations and eviction thresholds come off the top.
Other causes: an unbound PVC or a volume pinned to another zone, hostPort conflicts, and topology spread with DoNotSchedule. A ResourceQuota rejects the pod at creation instead, so look for that on the ReplicaSet's events.
Bash
kubectl get events -A --field-selector reason=FailedScheduling --sort-by=.lastTimestamp
kubectl describe node worker-3 |sed -n '/Allocated resources/,/Events/p'# requests vs allocatablekubectl get pvc -n payments # Pending claims block pods too
The app runs a distroless image with no shell, so kubectl exec -it ... -- sh fails with executable file not found. You need to look at its processes, files and network from inside the pod. How?
MediumDebugging, Networking and Scaling
Sample Answer
Add an ephemeral container with kubectl debug (GA since 1.25). It joins the running pod, so it shares the pod's network namespace: localhost reaches the app. With --target=<container> it also joins that container's process namespace, so ps shows the app's processes and you can read its filesystem through /proc/1/root, permissions allowing.
Ephemeral containers cannot be removed once added, have no probes or ports, and are not restarted. For a pod that crash-loops before you can attach, --copy-to creates a copy of the pod, optionally with --share-processes or a changed command, though a copy is a new pod and may not reproduce the bug. For node problems, kubectl debug node/worker-3 runs a pod in the host's namespaces with the node's filesystem at /host.
A pod in namespace web cannot resolve orders, a Service in namespace shop. Separately, CoreDNS logs show four or five lookups for every call your pods make to an external API. Explain both.
MediumDebugging, Networking and Scaling
Sample Answer
Service names have the form <service>.<namespace>.svc.cluster.local. A pod's /etc/resolv.conf lists search domains starting with its own namespace (web.svc.cluster.local svc.cluster.local cluster.local) and sets ndots:5. A bare orders expands to orders.web.svc.cluster.local, which does not exist. Use orders.shop or the full name.
ndots:5 explains the second problem. Any name with fewer than five dots is tried with each search domain before being tried as-is. api.example.com has two dots, so the resolver sends three doomed queries (A and AAAA for each) before the real one. That adds latency and load on CoreDNS.
Fixes: call external hosts with a trailing dot (api.example.com.), lower ndots through the pod's dnsConfig, and run NodeLocal DNSCache on large clusters. Also watch clients that cache DNS forever and miss Service changes.
Bash
1kubectl exec -n web deploy/frontend -- cat /etc/resolv.conf
2# search web.svc.cluster.local svc.cluster.local cluster.local3# options ndots:54kubectl run dnstest -n web --rm -it --image=busybox:1.37 --restart=Never -- nslookup orders.shop
You apply a default-deny NetworkPolicy to namespace payments, plus a policy that allows ingress from checkout. Now every pod in payments times out calling its database and cannot resolve any name. Why, and what is the minimal fix?
HardDebugging, Networking and Scaling
Sample Answer
By default pods are non-isolated: all traffic is allowed. A policy that selects a pod and lists Egress in policyTypes isolates it for egress, and from then on only connections allowed by some policy's egress rules get out. Policies are additive allow-lists, with no deny rules in the core API.
Your default-deny covered Ingress and Egress, and you only re-opened ingress. DNS to CoreDNS on port 53 and the database connection were both blocked. Allow egress to the kube-dns pods on UDP and TCP 53, then add a rule for the database.
Traps: a namespaceSelector and podSelector in the same to entry mean AND, while separate entries mean OR. And NetworkPolicy is enforced by the CNI plugin; a plugin without support silently ignores it.
An HPA targets 60% CPU with 3 to 20 replicas. At 9:00 traffic doubles and it scales up too late; a second HPA in the same cluster shows <unknown>/60% and never scales. Work through the math and the fixes.
HardDebugging, Networking and Scaling
Sample Answer
Utilization is measured against the CPU request, not the limit. If any container in the pod, sidecars included, has no CPU request, utilization is undefined and the HPA does nothing for that metric. That is the <unknown>; a missing metrics-server looks the same.
The formula is desired = ceil(current replicas times current / target). Six pods at 90% against 60% gives ceil(6 times 1.5) = 9. Ratios within 10% of 1.0 are ignored (configurable per HPA since 1.37).
Lag adds up: a 15-second sync loop, averaged metrics, and new pods that must pass readiness. Default scale-up may add 100% or 4 pods per 15 seconds, while scale-down waits 300 seconds. Scale on a leading signal such as requests per second or queue depth, and raise minReplicas before known peaks.
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.
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.
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.