浏览代码

Merge pull request #18707 from runcom/update-labels-doc-for-emtpy-lables

update syntax for empty value labels
moxiegirl 9 年之前
父节点
当前提交
18925f37ed
共有 2 个文件被更改,包括 16 次插入8 次删除
  1. 10 5
      docs/userguide/labels-custom-metadata.md
  2. 6 3
      man/Dockerfile.5.md

+ 10 - 5
docs/userguide/labels-custom-metadata.md

@@ -95,14 +95,17 @@ nested properties, the tool itself needs to implement this functionality.
 To add labels to an image, use the `LABEL` instruction in your Dockerfile:
 To add labels to an image, use the `LABEL` instruction in your Dockerfile:
 
 
 
 
-    LABEL [<namespace>.]<key>[=<value>] ...
+    LABEL [<namespace>.]<key>=<value> ...
 
 
-The `LABEL` instruction adds a label to your image, optionally with a value.
+The `LABEL` instruction adds a label to your image. A `LABEL` consists of a `<key>`
+and a `<value>`.
+Use an empty string for labels  that don't have a `<value>`,
 Use surrounding quotes or backslashes for labels that contain
 Use surrounding quotes or backslashes for labels that contain
 white space characters in the `<value>`:
 white space characters in the `<value>`:
 
 
     LABEL vendor=ACME\ Incorporated
     LABEL vendor=ACME\ Incorporated
-    LABEL com.example.version.is-beta
+    LABEL com.example.version.is-beta=
+    LABEL com.example.version.is-production=""
     LABEL com.example.version="0.0.1-beta"
     LABEL com.example.version="0.0.1-beta"
     LABEL com.example.release-date="2015-02-12"
     LABEL com.example.release-date="2015-02-12"
 
 
@@ -114,7 +117,8 @@ in a single instruction:
 Long lines can be split up by using a backslash (`\`) as continuation marker:
 Long lines can be split up by using a backslash (`\`) as continuation marker:
 
 
     LABEL vendor=ACME\ Incorporated \
     LABEL vendor=ACME\ Incorporated \
-          com.example.is-beta \
+          com.example.is-beta= \
+          com.example.is-production="" \
           com.example.version="0.0.1-beta" \
           com.example.version="0.0.1-beta" \
           com.example.release-date="2015-02-12"
           com.example.release-date="2015-02-12"
 
 
@@ -130,6 +134,7 @@ You can view the labels via the `docker inspect` command:
     "Labels": {
     "Labels": {
         "vendor": "ACME Incorporated",
         "vendor": "ACME Incorporated",
         "com.example.is-beta": "",
         "com.example.is-beta": "",
+        "com.example.is-production": "",
         "com.example.version": "0.0.1-beta",
         "com.example.version": "0.0.1-beta",
         "com.example.release-date": "2015-02-12"
         "com.example.release-date": "2015-02-12"
     }
     }
@@ -138,7 +143,7 @@ You can view the labels via the `docker inspect` command:
     # Inspect labels on container
     # Inspect labels on container
     $ docker inspect -f "{{json .Config.Labels }}" 4fa6e0f0c678
     $ docker inspect -f "{{json .Config.Labels }}" 4fa6e0f0c678
 
 
-    {"Vendor":"ACME Incorporated","com.example.is-beta":"","com.example.version":"0.0.1-beta","com.example.release-date":"2015-02-12"}
+    {"Vendor":"ACME Incorporated","com.example.is-beta":"", "com.example.is-production":"", "com.example.version":"0.0.1-beta","com.example.release-date":"2015-02-12"}
 
 
     # Inspect labels on images
     # Inspect labels on images
     $ docker inspect -f "{{json .ContainerConfig.Labels }}" myimage
     $ docker inspect -f "{{json .ContainerConfig.Labels }}" myimage

+ 6 - 3
man/Dockerfile.5.md

@@ -156,20 +156,23 @@ A Dockerfile is similar to a Makefile.
   the image.
   the image.
 
 
 **LABEL**
 **LABEL**
-  -- `LABEL <key>[=<value>] [<key>[=<value>] ...]`or 
+  -- `LABEL <key>=<value> [<key>=<value> ...]`or 
   ```
   ```
   LABEL <key>[ <value>]
   LABEL <key>[ <value>]
   LABEL <key>[ <value>]
   LABEL <key>[ <value>]
   ...
   ...
   ```
   ```
   The **LABEL** instruction adds metadata to an image. A **LABEL** is a
   The **LABEL** instruction adds metadata to an image. A **LABEL** is a
-  key-value pair. To include spaces within a **LABEL** value, use quotes and
+  key-value pair. To specify a **LABEL** without a value, simply use an empty
+  string. To include spaces within a **LABEL** value, use quotes and
   backslashes as you would in command-line parsing.
   backslashes as you would in command-line parsing.
 
 
   ```
   ```
   LABEL com.example.vendor="ACME Incorporated"
   LABEL com.example.vendor="ACME Incorporated"
-  or
   LABEL com.example.vendor "ACME Incorporated"
   LABEL com.example.vendor "ACME Incorporated"
+  LABEL com.example.vendor.is-beta ""
+  LABEL com.example.vendor.is-beta=
+  LABEL com.example.vendor.is-beta=""
   ```
   ```
 
 
   An image can have more than one label. To specify multiple labels, separate
   An image can have more than one label. To specify multiple labels, separate