Docker and Kubernetes Interview Questions for Backend Developers (2026)

By Preeti Verma

You do not have to be a DevOps engineer to be asked about containers. Most backend interviews now include a few Docker and Kubernetes questions, because your code has to run somewhere and teams want developers who understand how.

The good news is that the questions are usually practical, and you can answer them well with a small project behind you. Here are the ones that come up most, with what a strong answer includes.

Docker questions

1. What is the difference between an image and a container?

An image is a read-only template: your application, its runtime and its dependencies, packaged in layers. A container is a running instance of an image. You can start many containers from one image, the same way you can create many objects from one class.

2. Why use containers instead of virtual machines?

Containers share the host operating system's kernel, so they start in seconds and use far less memory than virtual machines, which each carry a full guest operating system. Say honestly that VMs give stronger isolation, and containers give speed and density. Containers also solve "it works on my machine": the same image runs in development, testing and production.

3. What happens in a Dockerfile, and how do layers matter?

Each instruction (FROM, COPY, RUN) creates a layer. Docker caches layers, so if nothing in a layer changed, it reuses it. The practical tip: put things that change rarely first (installing dependencies) and things that change often last (copying your source code), so rebuilds are fast.

4. What is a multi-stage build, and why use it?

You build your app in one stage that has the compiler and build tools (for Java, a JDK and Maven), then copy only the finished jar into a small runtime stage (a JRE). The final image is smaller and has fewer tools an attacker could use. This is a very common follow-up for Java developers.

5. CMD vs ENTRYPOINT

ENTRYPOINT defines the executable that always runs. CMD supplies default arguments, which a user can override when starting the container. A common pattern is ENTRYPOINT ["java", "-jar", "app.jar"] with CMD for default options.

6. How do you persist data and let containers talk to each other?

  • Volumes keep data outside the container's writable layer, so it survives restarts and removal.
  • Networks let containers reach each other by name. In docker-compose, services on the same network can call each other by service name.
  • Never store important data only inside a container. When it is removed, the data goes with it.

7. Why should containers not run as root, and what else makes an image safer?

If an attacker breaks into a process running as root, they have more power. Create a non-root user in the image. Also use small, trusted base images, avoid putting secrets in the image (pass them at run time), and scan images for known vulnerabilities.

8. What is docker-compose?

It describes several containers (your app, a database, a cache) in one YAML file and starts them together. It is great for local development and tests. Say that it is not a production orchestrator in the way Kubernetes is.

Kubernetes questions

9. What is Kubernetes, and why is it used?

It is a system that runs and manages containers across many machines. It handles starting containers, restarting failed ones, scaling, rolling out updates, and routing traffic. Say that you describe the desired state (for example "run three copies of this service") and Kubernetes works to keep reality matching it.

10. What is a pod?

The smallest deployable unit. A pod holds one or more containers that share a network address and storage. Usually it is one application container. Pods are ephemeral: they can be replaced at any time, with a new IP address, so you should never depend on a particular pod.

11. Pod vs ReplicaSet vs Deployment

  • A ReplicaSet keeps a set number of identical pods running.
  • A Deployment manages ReplicaSets and gives you rolling updates and rollbacks. You almost always create Deployments, not bare pods or ReplicaSets.

12. What is a Service, and what are the main types?

Pods come and go, so a Service gives them a stable address and load balances across them. Types:

  • ClusterIP (default): reachable only inside the cluster.
  • NodePort: opens a port on every node.
  • LoadBalancer: asks the cloud provider for an external load balancer.

An Ingress sits in front of services and routes HTTP traffic by host or path, often with TLS.

13. Liveness vs readiness probes

This is a favourite.

  • Liveness: "is the app stuck?" If it fails, Kubernetes restarts the container.
  • Readiness: "is the app ready to take traffic?" If it fails, the pod is removed from the service's endpoints, but not restarted. This is used during start-up or when a dependency is temporarily down.

For Spring Boot, mention the Actuator health endpoints and their liveness and readiness groups.

14. How do you handle configuration and secrets?

Use a ConfigMap for non-sensitive configuration and a Secret for sensitive values, and inject them as environment variables or mounted files. Be honest that Secrets are only base64-encoded by default, so enable encryption at rest and tight access rules, or use an external secret manager.

15. How does a rolling update work, and how do you roll back?

A Deployment replaces pods gradually, keeping the service available: it starts new pods, waits until they are ready (readiness probe), then stops old ones. If the new version is bad, kubectl rollout undo returns to the previous revision. This is why a correct readiness probe matters.

16. How does scaling work?

You can set replicas manually, or use a Horizontal Pod Autoscaler, which adds or removes pods based on metrics such as CPU use. Pair it with sensible resource requests and limits so the scheduler knows how much each pod needs, and so one pod cannot starve others.

17. A pod keeps restarting. How do you debug it?

A good answer is a short checklist: kubectl get pods to see the status (for example CrashLoopBackOff), kubectl describe pod for events, kubectl logs (and --previous for the last crashed run), then check the probes, memory limits (an out-of-memory kill is common for Java), configuration and secrets. For Java, mention setting the heap relative to the container memory limit.

Java-specific points that impress

  • Make the app container aware: set memory so the JVM respects the limit.
  • Handle graceful shutdown so in-flight requests finish when a pod is stopped.
  • Keep logs on standard output so the platform can collect them.
  • Make the service stateless so any pod can serve any request. See our microservices interview questions for the surrounding design questions.

How to practise

Containerise a small Spring Boot app, add a database with docker-compose, then deploy it to a local cluster such as minikube or kind. Break it on purpose: make the readiness probe fail, set a tiny memory limit, and watch what Kubernetes does. Then explain what you did out loud, which is how it will come up in the interview.

Practise this on GenQuest

  • Start a voice mock interview: answer out loud to an AI interviewer that knows your resume and the role, get follow-up questions, then read a scored report with a question-by-question review. Your first 15-minute interview is free.
  • Open the question banks: Core Java scenarios, Blind 75 and NeetCode 150, high-level and low-level design questions, and company-wise sheets, with a free preview and progress tracking.
  • Run a Recruiter Scan: add a job description and see how your resume matches it, with the few fixes that matter most.

FAQ

Do I need Kubernetes experience for a Java developer role? Often a working understanding is enough: the concepts above, and being able to read a deployment file. Hands-on cluster administration is usually for platform or DevOps roles.

Should I put Docker on my resume? Yes, if you have built and run your own images. Be ready to explain your Dockerfile. If you only followed a tutorial once, say so in the interview rather than overstating it.

Docker or Podman? Both run containers. Interviews mostly use Docker's terms, and the ideas transfer.

The takeaway

Explain images and containers, a good Dockerfile, pods, deployments and services, and the two probes, with one real example from a project. Practical answers beat memorised definitions.