Interview Prep · Docker & DevOps
The Docker Question That 90% of Candidates Fumble
Quick summary — the question and the fix
The question is simple: "What is the difference between a Docker image and a Docker container?" Most candidates answer with a one-line textbook definition. That is why they fumble — the interviewer is not checking definitions, they are checking understanding.
In this guide you will learn:
- The actual question — and why 90% fumble it.
- Image vs container — the answer that works.
- Layers, volumes, and networking — the follow-up questions.
- Common fumbles — what to avoid saying.
- How to practise — a simple routine.
SECTION 01The actual question
In almost every Docker interview, the question is some version of this: "What is the difference between a Docker image and a Docker container?" Here's why candidates fumble it:
| Candidate Answer | Why It Fails | What The Interviewer Wants |
|---|---|---|
| "An image is a file, a container runs it." | Too vague — sounds memorised | A clear mental model of the runtime |
| "A container is a lightweight VM." | Factually wrong — containers share the host kernel | Correct distinction between VM and container |
| "An image is a template for a container." | Correct, but only half the answer | How images become running containers |
| Silence or "I mostly use Docker Desktop." | Shows no hands-on understanding | Confidence and clarity |
Weak Answer:
"An image is like a file and a container is like
a process that runs it. You use docker run to
start it."
Why this fumbles:
- No layers, no isolation, no runtime explanation.
- Could have been read off a blog.
- Invites no follow-up questions.
Result: the interviewer moves on to a candidate
who actually builds and ships.
Strong Answer:
"An image is a read-only, layered template built
from a Dockerfile — it contains the filesystem,
dependencies, and metadata to start a process.
A container is a running instance of that image,
with its own writable layer and its own isolated
process and network namespace, sharing the host
kernel.
So the image is the blueprint; the container is
the running instance. You can start many
containers from the same image, and they don't
interfere with each other because each has its
own filesystem layer and namespace.
Result: the interviewer asks a follow-up — which
is exactly what you want.
SECTION 02Image vs container — the answer that works
The answer that gets you hired uses four building blocks. Keep these in your head:
| Building Block | What It Means | Example | Why Interviewers Care |
|---|---|---|---|
| Dockerfile | Instructions to build an image | FROM, COPY, RUN, CMD | Shows you can build, not just run |
| Image | Read-only layered filesystem | node:20-alpine | Shows understanding of caching |
| Container | Running instance with writable layer | docker run | Shows runtime and isolation knowledge |
| Namespace | Isolation of process, network, mounts | Each container has its own | Shows why containers are lightweight |
# Dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]
Each line becomes a layer.
Layers are cached — that is why COPY
package*.json comes before COPY . .
# Build the image
docker build -t myapp:1.0 .
# Run a container from the image
docker run -d -p 3000:3000 --name myapp myapp:1.0
# The image is now the blueprint.
# The container is a running instance.
# You can run many containers from one image.
docker run -d --name myapp-2 myapp:1.0
SECTION 03Layers, volumes, and networking
Once you answer the first question well, the follow-ups come fast. Here's what interviewers ask next:
| Follow-Up Topic | What They Ask | What A Strong Answer Covers |
|---|---|---|
| Layers | Why does build order matter? | Layer caching — copy dependency files first |
| Volumes | Where does data go when a container dies? | Volumes persist; container layer is ephemeral |
| Networking | How do two containers talk to each other? | User-defined bridge networks + service names |
| Compose | How do you run multiple services? | docker-compose with declared services |
services:
api:
build: .
ports:
- "3000:3000"
environment:
- DB_HOST=db
depends_on:
- db
db:
image: postgres:16
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:
Networking:
- Compose creates a user-defined bridge network.
- api can reach db using the service name "db".
- Each container still has its own namespace.
Volumes:
- pgdata is a named volume.
- It lives outside the container, so it survives
docker compose down (unless you use -v).
- The container's writable layer is ephemeral;
volumes are not.
SECTION 04Common fumbles
Here are the mistakes that make an otherwise decent Docker answer fail:
Fumble:
- "A container is a lightweight VM."
- "Docker is a type of virtual machine."
- "Images and containers are basically the same."
- No mention of namespaces or the kernel.
- Confusing the writable layer with the image.
Fix:
- Containers share the host kernel; VMs do not.
- A container is an isolated process, not a VM.
- An image is immutable; a container adds a
writable layer.
- Namespaces provide isolation; cgroups limit
resources.
Why it matters:
- The VM/container confusion is a red flag —
it says you have used Docker but never
understood it.
- The interviewer will always ask a follow-up
here. Getting it wrong ends the round.
SECTION 05How to practise
Here are tips to build a Docker answer you can trust under pressure:
- Build a small project — one Dockerfile, one image, one container.
- Explain it out loud — describe image vs container in 60 seconds.
- Practise follow-ups — layers, volumes, and networking.
- Use Compose — one file, two services, one network.
- Write your answer down — if it fits in 5 lines, it fits in your head.
SECTION 06Interview Q&A — Docker
Q1What is the difference between an image and a container?
An image is a read-only, layered template. A container is a running instance of that image with its own writable layer and isolated namespaces.
Q2How is a container different from a VM?
A VM runs a full guest OS on virtualised hardware. A container runs an isolated process that shares the host kernel — which makes it far lighter.
Q3Why does Dockerfile order matter?
Each instruction creates a layer. Layers are cached, so copying dependency files before application code means fewer rebuilds.
Q4What happens to data when a container is deleted?
The writable layer is deleted with the container. Data in a named or bind-mounted volume persists beyond the container.
Q5How do two containers communicate?
Through a user-defined bridge network. Containers reach each
other by service name — for example, api reaches
db at db:5432.
SECTION 07Test yourself — Docker quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 08Frequently asked questions
Why do 90% of candidates fumble this question?
Because they memorise one-line definitions instead of understanding the runtime. The interviewer is checking how the image becomes a container — not the definitions.
Is a container just a lightweight VM?
No. A VM has its own guest OS; a container is an isolated process that shares the host kernel.
Do I need to know namespaces and cgroups?
At least at a high level — namespaces provide isolation and cgroups limit resources. You do not need to memorise the flags.
What if I only use Docker Desktop?
That is a start, but you need to build one image and run one container from the command line to answer confidently.
How long should the answer be?
Sixty to ninety seconds. Long enough to cover image, container, and isolation — short enough that the interviewer can ask a follow-up.
SECTION 09Related reads
Classroom & online · Noida
Learn Docker by building, not memorising
Our Data Analytics Training Course includes hands-on Docker, containers, and interview prep so you can answer confidently in any round.
₹15,500 · full programme- Hands-on Docker labs
- Compose, volumes, networking
- Mock interviews with feedback
- Weekday & weekend batches