Docker and Kubernetes interview questions
13 questions, easy to hard. Read one, then answer it out loud: an AI interviewer follows up, hints when you're stuck and grades your answer.
Docker and Kubernetes interviews cover containers and orchestration: images and layers, networking and volumes, pods, deployments, services and scaling.
Containers
A teammate keeps mixing up Docker images and containers. Explain the difference, what happens when you run an image, and what happens to files written inside a container when it's removed.
What a strong answer covers
- How an image relates to the containers started from it.
- What starting a container actually creates and runs.
- Where a container's own changes are written.
- What survives when a container is deleted, and how to keep data that must.
Common mistake: Assuming files saved inside a container are permanent, then losing them when it is replaced.
- Write a Dockerfile
- easy
- Pro
You need to containerise a small Node.js web server for the first time. Talk through the Dockerfile you'd write, step by step, and why each step is there.
What a strong answer covers
- Choosing and pinning a sensible starting image.
- Getting dependencies installed in a repeatable way.
- Adding the code and telling the container how to start.
- Keeping unneeded or sensitive files out of what gets sent to the build.
Common mistake: Copying the whole project folder in, including local dependencies and secret files, with nothing to exclude them.
- Layer Caching
- medium
- Pro
Every time you change one line of code, your Docker build reinstalls all dependencies and takes five minutes. Explain how image layers and the build cache work, and how you'd reorder the Dockerfile to fix this.
What a strong answer covers
- How the build decides which earlier work it can reuse.
- Why one change can force everything after it to rebuild.
- Spotting which step is undoing the cache in this case.
- Ordering steps from rarely changing to often changing.
Common mistake: Blaming the network or the registry when the real cause is the order of steps in the Dockerfile.
- Shrink an Image
- medium
- Pro
Your production image is one and a half gigabytes because it contains compilers, test tools and the whole source tree. Explain why size matters and how you'd use a multi-stage build and other techniques to make it small.
What a strong answer covers
- The practical and security costs of a large image.
- Separating the tools needed to build from what is needed to run.
- Starting smaller and bringing in only what production needs.
- How image layers can keep deleted files around.
Common mistake: Deleting files in a separate later step and expecting the image to shrink, when the earlier layer still contains them.
- Volumes and Persistent Data
- medium
- Pro
You run Postgres in a container for local development, and every time you recreate the container your data disappears. Explain why, and compare named volumes and bind mounts as fixes.
What a strong answer covers
- Why the data vanished along with the container.
- Storage that Docker manages for you and that outlives any container.
- Sharing a folder from your own machine and when that suits better.
- Which option fits a database, and the care it still needs.
Common mistake: Assuming a volume means the data is safe for good, with no thought for backups.
- Local Development with Compose
- medium
- Pro
Your app needs a web server, a Postgres database and Redis, and new joiners spend a day setting them up. Explain how you'd use Docker Compose to start everything with one command, including how the services find each other.
What a strong answer covers
- Describing all the services and their settings in one file.
- How services address each other on their shared network.
- Why a service having started isn't the same as it being ready.
- Keeping data between runs and seeing code changes without rebuilding.
Common mistake: Pointing the app at localhost for the database, which inside a container refers to the app's own container.
- Harden a Container
- hard
- Pro
A security review flags that your containers run as root, use an unpinned latest base image and have never been scanned. Explain why each is a risk and how you'd harden the image and its runtime settings.
What a strong answer covers
- Why the user a container runs as matters if something is compromised.
- How floating image tags undermine reproducible builds.
- Finding known vulnerabilities and keeping images patched over time.
- Restricting what a running container is allowed to do.
Common mistake: Fixing the image once and never rebuilding it, so newly discovered vulnerabilities pile up unnoticed.
Kubernetes
You're deploying a web app to Kubernetes for the first time. Explain what a pod, a deployment and a service are, and how they work together to keep your app running and reachable.
What a strong answer covers
- What each of the three objects is responsible for, in plain terms.
- How the objects relate, so a failed pod is replaced and traffic still finds the app.
- Why pods come and go, and how callers keep reaching them anyway.
- The idea of describing the state you want and letting the cluster keep it that way.
Common mistake: Treating a pod like a long-lived server with a fixed address that clients can rely on.
- Readiness and Liveness Probes
- medium
- Pro
Your pods receive traffic before they've finished warming up, and one pod got stuck but was never restarted. Explain readiness and liveness probes and how you'd configure them for this app.
What a strong answer covers
- The different question each kind of probe answers and what Kubernetes does when it fails.
- Which probe addresses each of the two problems in the scenario.
- What a sensible health check should and shouldn't depend on.
- How to give a slow-starting app time before checks begin to count.
Common mistake: Pointing the liveness check at shared dependencies, so one outage restarts every pod at once.
- Requests and Limits
- medium
- Pro
Some of your pods are being killed with out-of-memory errors, while others are slow because of CPU throttling. Explain resource requests and limits for CPU and memory, and how you'd choose the values.
What a strong answer covers
- How the scheduler uses reserved resources to place pods on nodes.
- Why going over memory and going over CPU have very different consequences.
- How each symptom in the scenario points to a particular setting.
- Choosing values from measured usage and checking them again over time.
Common mistake: Picking numbers by guesswork and treating CPU and memory pressure as if they behaved the same way.
- Rolling Updates
- medium
- Pro
You push a new version of your deployment and want zero downtime. Explain how a Kubernetes rolling update works, which settings control its pace, and what makes it safe or unsafe.
What a strong answer covers
- How the old version is gradually replaced while the service keeps answering.
- The settings that trade rollout speed against spare capacity.
- Why the cluster needs a reliable signal that new pods can take traffic.
- Keeping old and new versions compatible during the overlap, and how to go back if needed.
Common mistake: Assuming the switch is instant, and forgetting that two versions share the database for a while.
- ConfigMaps and Secrets
- medium
- Pro
Your container image has database settings and an API key baked into it. Explain how you'd move configuration into ConfigMaps and Secrets, and what Kubernetes Secrets do and don't protect.
What a strong answer covers
- Separating ordinary settings from sensitive values, and how pods receive each.
- Why one image should run unchanged across every environment.
- How much protection Kubernetes Secrets really give out of the box, and what to add.
- What happens to running pods when a value changes, and options for rotating secrets.
Common mistake: Believing a Secret is encrypted just because its value isn't readable at a glance.
- Autoscale a Deployment
- hard
- Pro
Traffic to your service triples every evening and you're paying for idle pods all day. Explain how you'd autoscale with the Horizontal Pod Autoscaler and the cluster autoscaler, and the pitfalls to watch for.
What a strong answer covers
- How pod-level scaling decides when to add or remove copies, and which signal suits this service.
- How node-level scaling makes room for new pods and removes idle machines.
- The settings and resource figures that autoscaling depends on to behave sensibly.
- Ways scaling can misbehave or simply move the bottleneck elsewhere.
Common mistake: Scaling the pods without checking whether the nodes, start-up time or shared database can keep up.
Questions about practising
- How should I prepare for docker and kubernetes interview questions?
- Practise answering them out loud, not just reading them. Explaining an answer under follow-up questions is what interviews test. Work through the 13 questions here from easy to hard, and revisit the ones you struggle with.
- Can I practise docker and kubernetes interview questions with an AI?
- Yes. Open any question and start a voice session: an AI interviewer asks it, follows up on your answer, gives hints when you're stuck and grades your answer with written feedback when the call ends.
- Are these docker and kubernetes interview questions free?
- 2 of the 13 questions are free to practise. Sign in with Google, no card needed. Pro unlocks the rest, plus practice calls to your phone.