Skip to content
Lesson: Image VersionsSwitch
← DevOps Operations

Delivery and containers

Image Versions

Identify container images with tags and digests so you know exactly what is running.

When something breaks, "which version is running?" must have a precise answer. Container images give you two ways to name a version: tags and digests.

Tags

A tag is a human-friendly label after the colon:

registry.example.com/shop:1.4.0

You can add another tag to an existing image:

bash
docker tag shop:1.4.0 registry.example.com/shop:1.4.0
docker push registry.example.com/shop:1.4.0

A tag can be moved. Someone can push a different image under the same name, unless the registry is set to forbid it.

The latest tag

If you leave out the tag, Docker uses latest. It is only a default name. It does not mean "newest", and it changes only when someone pushes or tags an image with that name. Avoid it for deployments.

Digests

A digest is a hash of the image manifest, so it identifies exact content. List local digests:

bash
docker image ls --digests registry.example.com/shop
REPOSITORY                  TAG     DIGEST           IMAGE ID       CREATED        SIZE
registry.example.com/shop   1.4.0   sha256:9f2c...   4be1a0d3c7f2   2 hours ago    82MB

(The digest is shortened here.) For an image you built yourself, push it first, then record the digest that docker push reports.

Pull or run by digest with @:

bash
docker pull registry.example.com/shop@sha256:<full-digest>

If the content changes, the digest changes, so a digest reference always means the same image. The registry must still keep it.

Choosing a scheme

Common tags are a release number such as 1.4.0 or the Git commit ID:

bash
git rev-parse --short HEAD
3f9a1c2

Semantic versioning uses MAJOR.MINOR.PATCH: major for incompatible changes, minor for compatible features and patch for compatible fixes. A commit tag links an image straight back to its source. Use readable tags for people, and record the digest for certainty.

Try it

With Docker installed, run docker pull alpine:3.20, then docker image ls --digests alpine. Add your own tag with docker tag alpine:3.20 mycopy:1 and run docker image ls. Both names show the same image ID. The networking basics guide is useful if registry addresses and ports are new to you.

Check your understanding

Image Versions

All 3 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.