INTERVIEW PREP
Interview questions
570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.
Showing 76–90 of 188 questions
76.A container exits immediately after starting. How do you debug it?MidDocker
docker ps -a for the exit code, docker logs <id> for output, then docker run -it --entrypoint sh image to look inside. Common causes: the main process runs in the background, a missing env var, or wrong file permissions.
77.How do containers on the same host talk to each other?MidDocker
Put them on the same user-defined bridge network; Docker's embedded DNS resolves container names. The default bridge network has no name resolution.
78.What is a multi-stage build?MidDocker
A Dockerfile with several FROM stages: you build in a big image with compilers, then COPY --from=build only the result into a small runtime image. The final image is smaller and has fewer vulnerabilities.
79.Why does the order of lines in a Dockerfile matter?MidDocker
Each instruction is a cached layer, and a change invalidates every layer after it. Copy dependency files and install dependencies first, then copy the source code, so code changes don't reinstall everything.
80.What is the difference between ADD and COPY?MidDocker
COPY just copies files. ADD can also download URLs and unpack local tar files, which can surprise you. Use COPY unless you need what ADD does.
81.What is Docker Compose used for?MidDocker
It runs a multi-container app from one compose.yaml: services, networks, volumes and environment. It is great for local development and tests, for example an app plus Postgres plus Redis with docker compose up.
82.Why should a container not run as root, and how do you change it?MidDocker
If an attacker breaks out of the app, root in the container makes escaping to the host easier. Create a user and add USER app in the Dockerfile, and in Kubernetes set runAsNonRoot: true.
83.A Pod is in CrashLoopBackOff. How do you debug it?MidKubernetes
kubectl describe pod for events and the last state, kubectl logs pod --previous for the crashed container's output, check probes, config and resources, and use kubectl debug for an ephemeral shell if the image has none.
84.What is the difference between liveness and readiness probes?MidKubernetes
Readiness decides whether a Pod receives traffic; failing removes it from Service endpoints. Liveness decides whether to restart the container. A too-strict liveness probe causes restart loops under load.
85.What do resource requests and limits do?MidKubernetes
Requests are what the scheduler reserves and decide which node a Pod fits on. Limits cap usage: exceeding the memory limit gets the container OOM-killed, exceeding CPU gets it throttled.
86.A Pod is stuck in Pending. What do you check?MidKubernetes
kubectl describe pod shows the events. Common causes: not enough CPU or memory for its requests, taints without tolerations, node selectors or affinity that match no node, or a PersistentVolumeClaim that can't be bound.
87.How does a rolling update work, and how do you roll back?MidKubernetes
The Deployment creates a new ReplicaSet and shifts Pods over gradually, respecting maxSurge and maxUnavailable and waiting for readiness. Roll back with kubectl rollout undo deployment/web, and watch progress with kubectl rollout status.
88.What is the difference between a StatefulSet and a Deployment?MidKubernetes
StatefulSet Pods have stable names (db-0, db-1), their own PersistentVolume each, and start and stop in order. Use it for databases and clustered systems; use Deployments for stateless apps.
89.How does the Horizontal Pod Autoscaler work?MidKubernetes
It checks metrics (usually CPU or memory from metrics-server, or custom metrics) and changes the replica count to keep the target, for example 70% CPU. It needs resource requests set, because utilization is measured against them.
90.What is a PodDisruptionBudget?MidKubernetes
It limits how many Pods of an app can be down at once during voluntary disruptions like node drains and upgrades, for example minAvailable: 2. It doesn't protect against crashes or node failures.