Lesson 1 of 30
Three nouns get used almost interchangeably in casual conversation — image, container, registry — and interviews specifically probe whether you actually know which is which.
12 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
Two containers, web1 and web2, are both started from the same myapp:1.4.0 image. web1 is stopped and deleted. What happens to web2 and the image?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Three distinct objects, one vocabulary problem:
The relationship: you docker build a Dockerfile into an image, docker push that image to a registry, then docker pull and docker run it anywhere to produce a container.
docker build -t myapp:1.4.0 . # Dockerfile -> image
docker push registry.example.com/myapp:1.4.0 # image -> registry
docker run -d --name web1 myapp:1.4.0 # image -> container #1
docker run -d --name web2 myapp:1.4.0 # image -> container #2 — same image, independent process
One image, built once from a Dockerfile — a read-only blueprint. It never runs by itself.
web1 and web2 share the same read-only image layers underneath — Docker doesn't duplicate that data — but each gets its own writable layer, its own memory, and its own process. Stopping and deleting web1 never touches the image or web2; the image is the reusable blueprint, the container is one disposable instance of it.
myapp:latest is a mutable pointer that can point at a different image tomorrow — a real deploy pipeline pins an explicit version (myapp:1.4.0) or, more strictly, a content-addressed digest (myapp@sha256:...), because "latest" silently changing out from under a running system is a real, recurring incident category.docker pull able to detect "I already have this exact image" and skip re-downloading identical layers.docker run step, on whatever host pulls the image.docker start) until it's explicitly removed with docker rm — a common early mistake is assuming a stopped container is already gone."What's the difference between an image and a container?" is asked often enough to be a genuine filter question — not because it's hard, but because casual Docker usage lets people get by without ever needing the precise distinction. Answering with the blueprint/instance relationship, unprompted, signals real usage rather than memorized definitions.