Interview Q&A / Docker & Kubernetes

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What happens when you run docker run nginx and the image is not on your machine?

SHORT ANSWER

Docker looks locally, does not find nginx:latest, pulls it from Docker Hub, then creates and starts the container. With no tag given it uses latest, which is just a default tag name, not a guarantee of the newest version.

Explain it simply

It is like ordering a book from a bookstore. First the shop checks its shelf (local images). If the book is missing, it fetches it from the warehouse (registry), then hands it over.

A name like nginx is shorthand for docker.io/library/nginx:latest. Docker checks the local cache; if the image is absent it pulls each layer, showing progress per layer, and then runs it. If the image already exists locally, Docker does not check for updates, so you may keep running an old latest for months. Use docker pull nginx to refresh it.

latest is only the tag used when you give none. Publishers may or may not keep it current, and it can change under you. For repeatable builds pin a specific version such as nginx:1.27.

Example

bash
docker run nginx          # pulls nginx:latest if missing
docker pull nginx:1.27    # fetch a specific version
docker images             # list local images
docker run --pull always nginx   # force a fresh check

What to say in the interview

"Docker checks the local cache, pulls the image from the registry if it is missing, then creates and starts the container. With no tag it assumes latest, which is only a default name and can change, so I pin versions in real projects."

Common mistakes

  • Assuming latest means newest and that a local latest is auto-updated.

#docker#commands#images

Related questions

Practise more Docker & Kubernetes questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Docker & Kubernetes quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.