Using Labels in Container Images
A standard set of docker-formatted labels are being defined by Red Hat to use in official Red Hat images, as well as in images that are produced by Red Hat Independent Software Vendor (ISV) partners. Information stored in these labels can be viewed from:
- The This content is not included.Red Hat Container Catalog in the Tech Details section for each image.
- Each image itself, using commands such as the docker inspect and atomic images info commands.
To see upstream efforts from Project Atomic to define labels and other identifiers, refer to the Content from github.com is not included.Standard Container/Application Identifiers page.
Adding Labels at Build Time
Labels can be added to a container image at build time by including Content from docs.docker.com is not included.LABEL instructions to a Dockerfile. For example, here are some LABEL instructions that would go into a Dockerfile to add labels to a MariaDB database container image at build time:
LABEL "architecture"= "x86_64" LABEL "name"="rhscl/mariadb-100-rhel7" LABEL version="10.0" ...
Viewing Labels from the Red Hat Container Catalog
To view labels for an existing container image (for example, mariadb) from the This content is not included.Red Hat Container Catalog, go to the container catalog, search for mariadb, select the appropriate image, and select Tech Details from the image page. Labels are listed at the end of the Image Metadata information. For example:
Labels
io.k8s.description MariaDB is a multi-user, multi-threaded SQL database server
Version 10.1
vcs-ref 038365d843b36f9507078d710b4e86f36807645f
authoritative-source-url registry.access.redhat.com
Vendor Red Hat, Inc.
io.k8s.display-name MariaDB 10.1
version 10.1
com.redhat.component rh-mariadb101-docker
distribution-scope public
vendor Red Hat, Inc.
Name rhscl/mariadb-101-rhel7
Build_Host ip-10-29-120-226.ec2.internal
vcs-type git
Architecture x86_64
Release 3.4
BZComponent rh-mariadb101-docker
build-date 2016-10-31T06:51:03.889352Z
name rhscl/mariadb-101-rhel7
summary MariaDB is a multi-user, multi-threaded SQL database server
architecture x86_64
release 3.4
io.openshift.expose-services 3306:mysql
io.openshift.tags database,mysql,mariadb,mariadb101,rh-mariadb101
com.redhat.build-host ip-10-29-120-226.ec2.internal
Viewing Label Information from the Command Line
To view label information for an image that is accessible from a system running the docker service (for example, a mariadb image) using commands, type either of the following:
# docker inspect rhscl/mariadb-100-rhel7
...
"Labels": {
"Architecture": "x86_64",
"BZComponent": "rh-mariadb100-docker",
...
# atomic images info rhscl/mariadb-100-rhel7
Image Name: registry.access.redhat.com/rhscl/mariadb-100-rhel7:latest
io.k8s.description: MariaDB is a multi-user, multi-threaded SQL database server
Version: 10.0
vcs-ref: e6efd72fcf0daf102255ae44c59c1e408df8171b
authoritative-source-url: registry.access.redhat.com
Vendor: Red Hat, Inc.
io.k8s.display-name: MariaDB 10.0
...
Label Definitions
The following table describes container labels used in Red Hat container images. Some of these labels are added with LABEL instructions while others are created automatically at build time:
| Label Name | Description |
|---|---|
| authoritative-source-url | The URL of the registry containing the image (for example, registry.access.redhat.com). |
| build-date | The date and time on which the container was built (for example, 2016-10-31T06:51:03.126962Z). |
| *.build-host | Name of the build host, with the organization name appended (for example, "com.redhat.build-host":="ip-10-29-120-48.ec2.internal") |
| *.component | Component name of the image, with the organization name appended for use when entering a bug report at bugzilla.redhat.com (for example, "com.redhat.component":="rh-mariadb100-docker") |
| io.k8s.description | One-line description of image. |
| io.k8s.display-name | Name displayed with the image. |
| io.openshift.expose-services | Port number and service name exposed from the image and used by OpenShift (for example, 3306:mysql). |
| io.openshift.tags | Tags identifying the service to OpenShift. Includes the type of container, service name, and version information (for example, database,mysql,mariadb,mariadb100,rh-mariadb100). |
| name | The registry and image name associated with the image (for example, rhscl/mariadb-100-rhel7). |
| release | The release number associated with the image. |
| summary | One-line summary describing the image. |
| vcs-ref | Version control system reference number associated with the image (for example, e6efd72fcf0daf102255ae44c59c1e408df8171b). |
| vcs-type | Type of version control system being used to store the image (for example, git). |
| vendor | Company or organization producing the image (for example, Red Hat, Inc.). |
| version | The version number associated with the software the image contains. |
NOTE: Uppercase versions of some of the labels just shown were supported in earlier container images. Examples of these are Name, Release, Vendor, and others. Red Hat expects to remove those label names for RHEL 7.3.2. Therefore, you should not write scripts or put processes in place to automatically read those older-style labels.
There are some labels that are used specifically to provide information to the atomic command that tell it what docker or other command to run with different options to atomic. For example, the RUN label defines the full docker command and options to run when you run an atomic run command on a container. Here is a list of those labels:
| Label Name | Description |
|---|---|
| RUN | Describes command to run when atomic run is executed on the image (for example, RUN="docker run --name NAME IMAGE"). |
| INSTALL | Describes command to run when atomic install is executed on the image. This can be useful in creating configuration files or mounting directories from the host needed by the image. |
| UNINSTALL | Describes command to run when atomic uninstall is used to uninstall an image. For an uninstall, the command might remove files and unmount directories. |
| STOP | Describes command to run before stopping a container with atomic stop. |