Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Containers  ›  Lesson

Images, Tags and Registries

Containers 12 minAn image is a layered, read-only package stored in a registry and named registry/repository:tag, and a container is a running instance of it.

Images, Tags and Registries

A Kubernetes manifest never contains your code. It contains one line — image: ghcr.io/example/notes-web:1.2 — and the cluster fetches everything else. Reading that line correctly is a daily skill.

The rule

An image is the recipe's result; a container is one serving of it.

An image is a read-only package: the app, its runtime and its libraries, stacked in layers. A container is a running instance of an image. One image can start many containers, just as one cake recipe can feed many plates.

Images are built from a Dockerfile:

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "server.py"]

Each instruction adds a layer. Layers are cached and shared, so rebuilding after a code change only redoes the steps from the first changed line down. That is why dependencies are copied and installed before the rest of the code.

Images live in a registry — Docker Hub, GitHub Container Registry, or your cloud's registry. An image reference has parts:

ghcr.io / example/notes-web : 1.2
registry   repository         tag
  • No registry written? Docker Hub is assumed.
  • No tag written? latest is assumed.
  • A digest such as @sha256:3f1a… names one exact build and can never point elsewhere.

The shortcut

Read every image line right to left: which version (tag or digest), which app (repository), from where (registry). If the version part is missing or says latest, stop and pin it.

Reading an image referenceStep 1 of 4
  1. Right part: version

    ghcr.io/example/notes-web:1.2 — the tag is 1.2, a fixed release you chose.

The trap is latest. It is just a tag name, not a promise of the newest version, and it can point to a different build tomorrow. Two nodes may then run two different versions of "the same" app.

Drills

Answer fast — trust the rule.

quick drill

What is the relationship between an image and a container?

quick drill

In ghcr.io/example/notes-web:1.2, what is 1.2?

quick drill

A manifest says image: postgres. What does the cluster pull?

quick drill

Why is a digest reference safer than a tag for production?

Remember

  • An image is the packaged result; a container is one running serving of it.
  • Read references right to left: version, app, registry.
  • Trap: latest is just a movable label — pin a tag or digest.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWhy pin the tag?

A teammate writes image: notes-web in a manifest. Explain what the cluster will pull and why that is risky, then rewrite the line in a safer form.