Docker, Kubernetes and SQL Interview Questions: How to Explain the Difference
Three technical questions that come up again and again: Docker image vs container, Kubernetes Deployment vs StatefulSet, and when to use a SQL index. What a clear answer covers, and a structure you can reuse for any 'explain the difference' question.
"Explain the difference between X and Y" is one of the most common technical interview questions, because a short answer shows whether you understand a concept or only recognise its name. Here are three that come up often in DevOps, backend and data interviews, with what a clear answer covers and the follow-ups to expect.
A structure that works for any "explain the difference" question
- Define each term in one sentence.
- State the key difference in one sentence.
- Give a concrete example of when you would use each.
- Name one trade-off or exception.
- Stop and let the interviewer ask the next question.
Most weak answers skip step 3 or never reach step 4.
Docker image vs container
An image is a read-only template: a set of layers holding a filesystem and the default settings for running it. A container is a running (or stopped) instance created from an image. Docker adds a thin writable layer on top of the image's layers, plus runtime settings such as environment variables, networks and mounted volumes.
What a clear answer covers:
- Images are built once and shared; many containers can run from the same image.
- Anything a container writes to its own writable layer disappears when the container is removed. Data that must survive belongs in a volume.
- Two containers from the same image can behave differently because of their environment variables, mounted files or command-line options.
- To change an application you build and deploy a new image; you do not edit a running container.
Likely follow-ups: how layers make builds and pulls faster, and how volumes differ from bind mounts. Practise this question.
Kubernetes Deployment vs StatefulSet
A Deployment manages a set of interchangeable pods. Any replica can serve any request, pods get random names, and a rolling update can replace them in any order. It suits stateless services such as web APIs.
A StatefulSet gives each pod a stable identity: a fixed name with an ordinal (db-0, db-1), a stable network name through a headless Service, and its own persistent volume created from volumeClaimTemplates. By default its pods start, scale and update in order. It suits databases, queues and clustered systems where each member must keep its identity and data.
What a clear answer covers:
- A StatefulSet does not make an application stateful. The application still handles its own replication and recovery; the StatefulSet only gives each member a stable name and storage.
- Ordered rollout is safer for clusters but slower.
- A single-replica database can run under a Deployment with one persistent volume, but you lose stable identity for scaling out, and a careless update can start two pods against the same storage.
SQL indexes: what they are and when to use them
An index is a separate data structure, usually a B-tree, that lets the database find rows by the values in one or more columns without reading the whole table. It speeds up lookups, joins and sorting on those columns.
What a clear answer covers:
- Indexes cost something: every insert, update and delete must update them, and they take storage.
- They help most on selective filters, where a value matches a small share of rows. On a column where most rows share a value, the planner may scan the table anyway.
- In a composite index, column order matters: an index on (customer_id, created_at) helps queries that filter by customer_id, but not queries that filter only by created_at.
- A covering index includes every column a query needs, so the database can answer from the index alone.
- You check whether an index is used by reading the query plan, for example with EXPLAIN.
Practise out loud
Reading a good answer is easier than giving one. Say your answer aloud, time it at under two minutes, and check it against the structure above. On the interview practice pages you can try each question and compare your answer with an illustrative one. Interview Coach in JobAutoPilot checks which ideas your answer covers on reviewed questions and gives you a follow-up round; AI feedback can make mistakes, so treat it as practice, not a verdict.