Docker & Kubernetes Interview Questions and Answers

36 questions with short, clear answers · Updated December 2026

Containers are asked about in almost every DevOps, cloud and platform engineering interview. This page starts with Docker, moves through Kubernetes architecture and objects, and ends with the troubleshooting questions interviewers use to see whether you have run a real cluster.

The answers match current Kubernetes: Docker Engine is no longer used inside clusters (containerd or CRI-O is), PodSecurityPolicy has been replaced by Pod Security Admission, and the Gateway API is the newer alternative to Ingress.

Docker

Q1. What is the difference between a container and a virtual machine?

A virtual machine runs a full guest operating system on a hypervisor, so it is heavier and slower to start. A container shares the host's kernel and isolates processes with namespaces and cgroups, so it is lightweight, starts in seconds and packs densely. VMs give stronger isolation; containers give speed and portability, and in the cloud they usually run inside VMs.

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

An image is a read-only template made of layers: the filesystem, application and metadata such as the start command. A container is a running (or stopped) instance of an image with a thin writable layer on top. Many containers can run from one image, and changes inside a container are lost when it is removed unless stored in a volume.

Q3. What is the difference between CMD and ENTRYPOINT?

ENTRYPOINT sets the executable that always runs; CMD gives default arguments (or a default command if there is no ENTRYPOINT) that are replaced by whatever you pass to docker run. A common pattern is ENTRYPOINT ["python", "app.py"] with CMD ["--port", "8080"]. Use the exec (JSON array) form so the process gets signals such as SIGTERM correctly.

Q4. What is a multi-stage build?

A Dockerfile with several FROM stages: the first stage has the compilers and build tools and builds the application, and the final stage copies only the built output into a small runtime image (slim, distroless or alpine). The result is a much smaller image with fewer vulnerabilities, because build tools and source code are left behind.

Q5. How do you make a Docker image smaller and more secure?

Use a small, trusted base image and pin its version; use multi-stage builds; add a .dockerignore; combine package installs and clean caches in the same RUN; order instructions so rarely changing layers come first for better caching; run as a non-root USER; never bake secrets into layers (use build secrets); and scan the image with a tool such as Trivy or Docker Scout.

Q6. What is the difference between a volume and a bind mount?

A volume is storage managed by Docker (under Docker's data directory), portable and the recommended way to persist data such as a database. A bind mount maps a specific host path into the container, which is handy in development for live code reloading but ties the container to the host's file layout.

Q7. Explain Docker network types.

bridge (default): containers on the same host get private IPs, and on a user-defined bridge they can reach each other by name; host: the container uses the host's network directly; none: no networking; overlay: connects containers across several hosts (Swarm); macvlan: gives a container its own MAC address on the physical network. Ports are published to the host with -p host:container.

Q8. What is Docker Compose used for?

Compose defines a multi-container application (for example web, database and cache) with its networks and volumes in a compose.yaml file, and starts it all with docker compose up. It is ideal for local development and simple single-host deployments; for production across many machines you use an orchestrator such as Kubernetes.

Kubernetes architecture

Q9. Explain the Kubernetes architecture.

The control plane has the kube-apiserver (the front door for every request), etcd (the key-value store holding cluster state), the kube-scheduler (chooses a node for each new pod) and the kube-controller-manager (runs controllers that move actual state towards desired state), plus a cloud-controller-manager in the cloud. Each worker node runs the kubelet (starts and watches pods), kube-proxy (service networking, unless the CNI replaces it) and a container runtime such as containerd.

Q10. Does Kubernetes still use Docker?

Not as the runtime inside the cluster. Kubernetes talks to runtimes through the Container Runtime Interface, and the dockershim adapter for Docker Engine was removed in version 1.24. Clusters use containerd or CRI-O. Images built with Docker still work everywhere, because they follow the OCI image standard.

Q11. What happens when you run kubectl apply -f deployment.yaml?

kubectl sends the object to the API server, which authenticates and authorises the request, runs admission controllers and stores it in etcd. The Deployment controller creates a ReplicaSet, the ReplicaSet controller creates Pods, the scheduler assigns each Pod to a node, and the kubelet on that node pulls the image through the container runtime and starts the containers, reporting status back to the API server.

Q12. Why is etcd important, and how do you protect it?

etcd holds the entire cluster state: every object, secret and configuration. If it is lost without a backup, the cluster has to be rebuilt. Run it with an odd number of members (3 or 5) for quorum, take regular snapshots (etcdctl snapshot save), encrypt secrets at rest, and restrict access with TLS. Managed services such as EKS, AKS and GKE run and back up etcd for you.

Q13. What is a namespace, and what does it not isolate?

A namespace groups resources inside a cluster for teams or environments, and RBAC, resource quotas and network policies can be applied per namespace. It does not isolate the network by default (pods in different namespaces can talk unless a NetworkPolicy blocks it), and nodes, persistent volumes and cluster-wide resources are not namespaced.

Pods and workloads

Q14. What is a Pod, and why can it have more than one container?

A Pod is the smallest deployable unit: one or more containers that share a network namespace (same IP, talk over localhost) and can share volumes, always scheduled together on one node. Extra containers are for tightly coupled helpers, such as a log shipper or proxy sidecar, or init containers that run setup before the main container starts. Native sidecar containers (init containers with restartPolicy: Always) are now a stable feature.

Q15. What is the difference between a Deployment, a StatefulSet and a DaemonSet?

A Deployment runs interchangeable stateless pods and handles rolling updates through ReplicaSets. A StatefulSet gives each pod a stable name (db-0, db-1), stable network identity and its own persistent volume, and starts them in order, for databases and clustered apps. A DaemonSet runs one pod on every (or selected) node, for log collectors, monitoring agents and CNI plugins.

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

When the pod template changes, the Deployment creates a new ReplicaSet and shifts pods from old to new gradually, controlled by maxSurge (extra pods allowed) and maxUnavailable (pods that may be down). New pods only receive traffic once their readiness probe passes. kubectl rollout status watches it, and kubectl rollout undo deployment/<name> goes back to the previous revision.

Q17. What is the difference between liveness, readiness and startup probes?

A liveness probe checks whether the container is still working; if it fails, the kubelet restarts the container. A readiness probe checks whether it can serve traffic; if it fails, the pod is removed from Service endpoints but not restarted. A startup probe gives slow-starting apps time to boot before liveness checks begin. A badly set liveness probe, for example one that checks the database, can cause restart loops.

Q18. What are resource requests and limits, and what are QoS classes?

Requests are what the scheduler reserves for a container; limits are the maximum it may use. Exceeding the memory limit gets the container OOMKilled; exceeding the CPU limit only throttles it. Pods where every container has requests equal to limits are Guaranteed, pods with some requests are Burstable, and pods with none are BestEffort; under memory pressure BestEffort pods are evicted first.

Q19. What are Jobs and CronJobs?

A Job runs pods until a set number complete successfully, retrying failures up to backoffLimit, for one-off tasks such as a database migration. A CronJob creates Jobs on a schedule written in cron syntax, for backups or reports, with settings for concurrency and how many old Jobs to keep.

Q20. How do you control which node a pod runs on?

nodeSelector and node affinity attract pods to nodes with certain labels (for example GPU nodes). Taints on a node repel pods unless they have a matching toleration, which is used to reserve nodes. Pod affinity and anti-affinity place pods near or away from other pods, for example spreading replicas across nodes, and topologySpreadConstraints spread them evenly across zones.

Services and networking

Q21. What are the Service types in Kubernetes?

ClusterIP (default): a stable virtual IP reachable only inside the cluster. NodePort: opens a port (30000–32767 by default) on every node. LoadBalancer: asks the cloud for an external load balancer. ExternalName: a DNS alias to an outside name. A headless Service (clusterIP: None) returns the pod IPs directly, used with StatefulSets.

Q22. How does a Service find its pods?

Through a label selector. The control plane keeps EndpointSlices listing the IPs of ready pods whose labels match, and kube-proxy (or an eBPF-based CNI such as Cilium) programs the nodes to load-balance traffic for the Service IP to those pods. Pods find Services by DNS names such as my-svc.my-namespace.svc.cluster.local, provided by CoreDNS.

Q23. What is the difference between Ingress and the Gateway API?

Ingress defines HTTP routing rules (host and path to Service) that an ingress controller implements; much of its behaviour depends on controller-specific annotations. The Gateway API is the newer, more expressive standard: it separates GatewayClass, Gateway and HTTPRoute so platform and app teams own different parts, and it supports traffic splitting, header matching and other protocols natively. The community ingress-nginx controller has been retired, so new setups usually choose the Gateway API or another maintained controller.

Q24. What is a NetworkPolicy?

A NetworkPolicy is a firewall for pods: it selects pods by label and allows ingress and egress only from the listed pods, namespaces or IP blocks. By default all pods can talk to all pods; a common start is a default-deny policy per namespace plus explicit allows. It only works if the CNI plugin enforces policies (Calico and Cilium do).

Q25. What is a CNI plugin?

The Container Network Interface plugin gives each pod an IP and connects pods across nodes. Examples are Calico, Cilium (eBPF-based, with network policies and observability), Flannel, and the cloud plugins such as the Amazon VPC CNI and Azure CNI, which give pods IPs from the cloud network.

Configuration, storage and security

Q26. What is the difference between a ConfigMap and a Secret, and are Secrets secure?

Both inject configuration into pods as environment variables or files; Secrets are meant for sensitive data. By default a Secret is only base64-encoded, not encrypted, so anyone who can read Secrets or etcd can read the value. Turn on encryption at rest, restrict access with RBAC, and for production consider an external store (Vault, AWS Secrets Manager, Azure Key Vault) through the External Secrets Operator or the Secrets Store CSI driver.

Q27. Explain PersistentVolume, PersistentVolumeClaim and StorageClass.

A PersistentVolumeClaim is a pod's request for storage (size and access mode such as ReadWriteOnce). A StorageClass describes a kind of storage (for example gp3 EBS or Azure Premium SSD) and lets a CSI driver create the PersistentVolume automatically when a claim is made. The PersistentVolume is the actual piece of storage; its reclaim policy decides whether it is deleted or kept when the claim is removed.

Q28. How does RBAC work in Kubernetes?

A Role (namespaced) or ClusterRole (cluster-wide) lists allowed verbs (get, list, create, delete...) on resources. A RoleBinding or ClusterRoleBinding grants that role to users, groups or ServiceAccounts. Pods use ServiceAccounts, so give each application its own ServiceAccount with only the permissions it needs, and check access with kubectl auth can-i.

Q29. What replaced PodSecurityPolicy?

PodSecurityPolicy was removed in Kubernetes 1.25. Pod Security Admission replaced it: you label a namespace with a Pod Security Standard level (privileged, baseline or restricted) in enforce, audit or warn mode. For custom rules, teams use policy engines such as Kyverno or OPA Gatekeeper, or the built-in ValidatingAdmissionPolicy.

Q30. How does autoscaling work in Kubernetes?

The Horizontal Pod Autoscaler changes the number of replicas based on CPU, memory or custom metrics (it needs metrics-server or a metrics adapter, and requests set on pods). The Vertical Pod Autoscaler adjusts the requests of pods. Cluster Autoscaler or Karpenter adds nodes when pods are Pending for lack of space and removes empty nodes. KEDA scales on events such as queue length, including to zero.

Q31. What is Helm?

Helm is the package manager for Kubernetes. A chart is a set of templated manifests with default values in values.yaml; you install it as a release with your own values, upgrade it, and roll back to an earlier revision with helm rollback. Charts are shared through repositories or OCI registries.

Troubleshooting scenarios

Q32. A pod is in CrashLoopBackOff. How do you debug it?

The container starts and keeps exiting. Run kubectl describe pod to see the exit code and events, and kubectl logs <pod> --previous to see the last crash's output. Common causes are an application error or missing configuration (env variable, Secret, ConfigMap), a wrong command, a failing liveness probe, or exit code 137 meaning it was OOMKilled and needs more memory.

Q33. A pod is stuck in Pending. What do you check?

Pending means it has not been scheduled. kubectl describe pod shows the reason in the events: not enough CPU or memory on any node for its requests, node selectors or affinity that no node matches, taints without tolerations, or a PersistentVolumeClaim that cannot be bound (for example a volume in another availability zone). Fix the cause or let the cluster autoscaler add nodes.

Q34. What does ImagePullBackOff mean?

The kubelet cannot pull the image. Check the image name and tag for typos, that the tag exists in the registry, that the node can reach the registry, and that a private registry has credentials (an imagePullSecret, or node or workload IAM permission for ECR, ACR or Artifact Registry). Rate limits on public registries can also cause it.

Q35. A Service is not reaching its pods. How do you troubleshoot?

Check that the Service selector matches the pod labels exactly and that kubectl get endpointslices shows pod IPs (no IPs usually means a selector mismatch or pods that are not ready). Check that targetPort matches the port the container listens on, test from another pod with curl to the Service name, and check NetworkPolicies that might block the traffic.

Q36. A node shows NotReady. What do you do?

kubectl describe node shows conditions such as MemoryPressure, DiskPressure or a kubelet that stopped posting status. On the node, check the kubelet and container runtime services (systemctl status kubelet, journalctl -u kubelet), disk space and network to the API server. Cordon and drain the node if it needs maintenance; in a managed node group you can simply replace it.

Learn Docker & Kubernetes hands-on

Knowing the answers is half the job; interviewers also ask what you have built. Technical Guftgu's Docker & Kubernetes training is taught in Hindi with live classes, labs and project work, plus resume and mock-interview help. We do not promise or guarantee job placement.

Docker & Kubernetes training near you

More interview questions

TECHNICAL GUFTGU

© 2026 Technical Guftgu. All rights reserved.