Challenge
DifficultyEasy
Community stats167 solved of 219 attempts

Read OCI Image Labels Using ctr

Read the labels stored in a container image's config with ctr, and trace an image back to the Git commit it was built from.

Premium Challenge

Upgrade your membership to unlock this and all other premium materials.

Upgrade

A container image can carry labels in its config. Build tools set them from the LABEL instruction of a Dockerfile or the --label flag of docker build, and the labels travel with the image to every registry and machine. In this challenge, you will read the labels of an image stored in containerd using ctr.

The machine has a registry.iximiuz.com/billing-api:1.4.2 image in containerd's default namespace. Its build recorded the Git commit of the source code in the standard org.opencontainers.image.revision label. Find the commit ID that the image was built from.

Hint 1

The LABELS column of sudo ctr image ls will not help here. It shows containerd labels, which ctr image label attaches to containerd's own record of an image. Those are a different kind of label, see Add and Read containerd Image Labels Using ctr challenge for more.

Other ctr commands may print containerd labels as well, so make sure that the value you find comes from the image config, where the OCI labels live under config.Labels.

Hint 2

The ctr image inspect command prints the tree of an image: its manifest, its config, and its layers. One of its flags adds the content of each of these blobs to the output.

Hint 3

The OCI labels are in the JSON content of the config blob (application/vnd.oci.image.config.v1+json), under config.Labels. The Labels boxes that ctr image inspect prints next to each blob show something else. They are containerd labels of the blobs in containerd's content store, such as containerd.io/gc.ref.content.config.