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 229 questions
76.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.
77.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.
78.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.
79.How do you secure container images in a pipeline?SeniorDocker
Pin base images by digest, run as non-root, drop capabilities, scan with Trivy or Grype and fail on critical CVEs, generate an SBOM, sign images with cosign and verify signatures at deploy time.
80.What actually isolates a container from the host?SeniorDocker
Linux namespaces (PID, network, mount, UTS, IPC, user) isolate what it sees; cgroups limit what it uses; seccomp, capabilities and AppArmor/SELinux limit what it can do. It shares the host kernel, so kernel exploits can escape; gVisor or Kata add a stronger boundary.
81.Why should a container run one main process, and what is PID 1's job?SeniorDocker
Docker watches PID 1: when it exits, the container stops. PID 1 must handle signals and reap zombie processes; many apps don't, so use exec in entrypoint scripts or --init (tini). One process per container also keeps logs, scaling and restarts simple.
82.What are cgroups and namespaces?SeniorDocker
Namespaces give a container its own view of processes, network, mounts, hostname and users. Cgroups limit and measure its CPU, memory and I/O. Together they make a container: an isolated, limited process on a shared kernel.
83.How do you choose a base image?SeniorDocker
Prefer small, maintained images: distroless or -slim variants, or Alpine if musl is fine for your app. Pin versions or digests, rebuild often to pick up security fixes, and scan images in CI.
84.What is the difference between Docker and containerd, and why did Kubernetes drop dockershim?SeniorDocker
containerd is the container runtime that actually runs containers; Docker Engine adds a CLI, builds and more on top of it. Kubernetes talks to runtimes through CRI, which containerd and CRI-O support directly, so the extra Docker layer (dockershim) was removed in 1.24. Images built with Docker still run unchanged.
85.What is the difference between a Deployment, a ReplicaSet and a Pod?BeginnerKubernetes
A Pod runs one or more containers. A ReplicaSet keeps a number of identical Pods running. A Deployment manages ReplicaSets to give rolling updates and rollbacks; you normally only create Deployments.
86.How does a Service find its Pods?BeginnerKubernetes
Through its label selector. The endpoints controller lists ready Pods whose labels match, and kube-proxy (or the CNI) routes the Service's virtual IP to them.
87.What are the main parts of a Kubernetes cluster?BeginnerKubernetes
The control plane runs the API server, etcd (the database), the scheduler and the controller manager. Each worker node runs kubelet, a container runtime and kube-proxy (or a CNI that replaces it). You talk to the API server with kubectl.
88.What is a namespace used for?BeginnerKubernetes
It groups resources inside one cluster, for example per team or environment, and is the unit for RBAC, resource quotas and network policies. It is not a hard security boundary on its own.
89.What is the difference between a ConfigMap and a Secret?BeginnerKubernetes
Both hold configuration for Pods. Secrets are meant for sensitive data and are base64-encoded, not encrypted by default; turn on encryption at rest and limit access with RBAC, or use an external secret manager.
90.What are the Service types?BeginnerKubernetes
ClusterIP (internal only, the default), NodePort (a port on every node), LoadBalancer (a cloud load balancer) and ExternalName (a DNS alias). Ingress or Gateway API sit on top to route HTTP by host and path.