The LABEL instruction

The LABEL instruction enables you to add key-value pairs as metadata to your Docker images. These metadata can be further leveraged to provide meaningful Docker image management and orchestration.

The syntax of the LABEL instruction is as follows:

LABEL <key-1>=<val-1> <key-2>=<val-2> ... <key-n>=<val-n> 

The LABEL instruction can have one or more key-value pairs. Though a Dockerfile can have more than one LABEL instruction, it is recommended that you use a single LABEL instruction with multiple key-value pairs.

Here is an example of the LABEL instruction:

LABEL version="2.0"  
release-date="2016-08-05"

The preceding label keys are very simple and this could result in naming conflicts. Hence Docker recommends using namespaces to label keys using the reverse domain notation. There is a community project called Label Schema that provides shared namespace. The shared namespace acts as a glue between the image creators and tool builders to provide standardized Docker image management and orchestration. Here is an example of the LABEL instruction using Label Schema:

LABEL org.label-schema.schema-version="1.0"  
org.label-schema.version="2.0"
org.label-schema.description="Learning Docker Example"
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset