World map

 

BM: Baca dalam Bahasa Melayu

World D2: Recipes

Tags with SemVer, Git SHA and labels

You will learn: to name every image so anyone can tell exactly what is inside.

Checked with Docker Engine 29 on 31 Oct 2026

The problem

The live site runs diary:latest. It breaks at lunch. Which version is it?

Pick one answer.

Watch

One build gets two tags, diary:1.2.0 and diary:sha-3f2a9c1. docker images shows the same IMAGE ID for both. Docker transcript: $ docker build -t diary:1.2.0 -t diary:sha-3f2a9c1 . [+] Building 0.1s (7/7) FINISHED docker:default => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 157B 0.0s => [internal] load metadata for docker.io/library/nginx:1.30-alpine 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [1/2] FROM docker.io/library/nginx:1.30-alpine@sha256:0e52bd054126cdc0 0.0s => => resolve docker.io/library/nginx:1.30-alpine@sha256:0e52bd054126cdc0 0.0s => [internal] load build context 0.0s => => transferring context: 237B 0.0s => [2/2] COPY index.html style.css /usr/share/nginx/html/ 0.0s => exporting to image 0.1s => => exporting layers 0.0s => => exporting manifest sha256:edf14bcbf50fc123879440a4c4421796cf24832bb 0.0s => => exporting config sha256:5954acf9ac3f89a825a1da5b54e47a6585e684fffcf 0.0s => => exporting attestation manifest sha256:2b823f771dcdaa00e2c6cf84ac554 0.0s => => exporting manifest list sha256:5bdca19bd493ff4cc37db8939d7389d63e05 0.0s => => naming to docker.io/library/diary:1.2.0 0.0s => => unpacking to docker.io/library/diary:1.2.0 0.0s => => naming to docker.io/library/diary:sha-3f2a9c1 0.0s => => unpacking to docker.io/library/diary:sha-3f2a9c1 0.0s $ docker images diary i Info → U In Use IMAGE ID DISK USAGE CONTENT SIZE EXTRA diary:1.2.0 5bdca19bd493 92.6MB 26.1MB diary:sha-3f2a9c1 5bdca19bd493 92.6MB 26.1MB

Your laptop~/diary

  • No open hatches

Lunchboxes (containers)

  • No containers yet

Frozen packs (images)

  • nginx:1.30-alpine8 layers · 93.5MB

0 containers (0 running), 1 images, 0 lockers.

One pack, two stickers. 1.2.0 is a Semantic Versioning (SemVer): Version numbers in three parts: MAJOR.MINOR.PATCH. tag for people. sha-3f2a9c1 names the exact Git commit. Same ID: nothing was copied.

Predict

SemVer is MAJOR.MINOR.PATCH. You fix a typo on the diary page. What does 1.2.0 become?

Pick one answer.

Try it

Build the command for version 1.2.1. Tag it with your commit’s short id too.

Tap the pieces in the right order.

…

Try it

Now for real. Build diary with two tags: 1.2.0 and sha-3f2a9c1.

Your laptop~/diary

  • No open hatches

Lunchboxes (containers)

  • No containers yet

Frozen packs (images)

  • nginx:1.30-alpine8 layers · 93.5MB

0 containers (0 running), 1 images, 0 lockers.

Watch

The recipe has a LABEL line with the title. The build adds a version label. docker inspect prints all labels, the nginx maintainer label too. Docker transcript: $ cat Dockerfile FROM nginx:1.30-alpine LABEL org.opencontainers.image.title="My diary" COPY index.html style.css /usr/share/nginx/html/ $ docker build --label org.opencontainers.image.version=1.2.0 -t diary:1.2.0 . [+] Building 0.1s (7/7) FINISHED docker:default => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 157B 0.0s => [internal] load metadata for docker.io/library/nginx:1.30-alpine 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [1/2] FROM docker.io/library/nginx:1.30-alpine@sha256:0e52bd054126cdc0 0.0s => => resolve docker.io/library/nginx:1.30-alpine@sha256:0e52bd054126cdc0 0.0s => [internal] load build context 0.0s => => transferring context: 237B 0.0s => [2/2] COPY index.html style.css /usr/share/nginx/html/ 0.0s => exporting to image 0.1s => => exporting layers 0.0s => => exporting manifest sha256:9409da405cca8d25a8a07705549a3091141ed3712 0.0s => => exporting config sha256:598541a38e02cf38d0d87c261ab9ebb1da88603d82d 0.0s => => exporting attestation manifest sha256:703edca29323e0a86011afe9d74ee 0.0s => => exporting manifest list sha256:dc422fcfbe8a9fc18df5bed451c2659b6bc4 0.0s => => naming to docker.io/library/diary:1.2.0 0.0s => => unpacking to docker.io/library/diary:1.2.0 0.0s $ docker inspect --format "{{json .Config.Labels}}" diary:1.2.0 {"maintainer":"NGINX Docker Maintainers <docker-maint@nginx.com>","org.opencontainers.image.title":"My diary","org.opencontainers.image.version":"1.2.0"}

Your laptop~/diary

  • No open hatches

Lunchboxes (containers)

  • No containers yet

Frozen packs (images)

  • nginx:1.30-alpine8 layers · 93.5MB

0 containers (0 running), 1 images, 0 lockers.

A label: A sticker on the pack with a fact, like its version or source code link. is a fact stuck on the pack. The standard names start with org.opencontainers.image., like title, version and source. docker inspect reads them.

Check

Would you run this tag on the live site?

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now tag and label images clearly.

      Go deeper (optional)

      docker tag diary:1.2.0 diary:1.2 adds a third sticker that you can move to 1.2.1 later. In World C2, a pipeline makes these tags for you. Labels from --label and LABEL end up in the same list.

      Real mission

      1. git rev-parse --short HEAD
      2. docker images

      0 of 3 steps done · Your ticks are saved.