github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/docs/reference/commandline/secret_create.md (about)

     1  ---
     2  title: "secret create"
     3  description: "The secret create command description and usage"
     4  keywords: ["secret, create"]
     5  ---
     6  
     7  <!-- This file is maintained within the docker/docker Github
     8       repository at https://github.com/docker/docker/. Make all
     9       pull requests against that repo. If you see this file in
    10       another repository, consider it read-only there, as it will
    11       periodically be overwritten by the definitive file. Pull
    12       requests which include edits to this file in other repositories
    13       will be rejected.
    14  -->
    15  
    16  # secret create
    17  
    18  ```Markdown
    19  Usage:  docker secret create [OPTIONS] SECRET
    20  
    21  Create a secret using stdin as content
    22  Options:
    23        --help         Print usage
    24    -l, --label list   Secret labels (default [])
    25  ```
    26  
    27  Creates a secret using standard input for the secret content. You must run this
    28  command on a manager node.
    29  
    30  ## Examples
    31  
    32  ### Create a secret
    33  
    34  ```bash
    35  $ cat secret.json | docker secret create secret.json
    36  mhv17xfe3gh6xc4rij5orpfds
    37  
    38  $ docker secret ls
    39  ID                          NAME                    CREATED                                   UPDATED                                   SIZE
    40  mhv17xfe3gh6xc4rij5orpfds   secret.json             2016-10-27 23:25:43.909181089 +0000 UTC   2016-10-27 23:25:43.909181089 +0000 UTC   1679
    41  ```
    42  
    43  ### Create a secret with labels
    44  
    45  ```bash
    46  $ cat secret.json | docker secret create secret.json --label env=dev --label rev=20161102
    47  jtn7g6aukl5ky7nr9gvwafoxh
    48  
    49  $ docker secret inspect secret.json
    50  [
    51      {
    52          "ID": "jtn7g6aukl5ky7nr9gvwafoxh",
    53          "Version": {
    54              "Index": 541
    55          },
    56          "CreatedAt": "2016-11-03T20:54:12.924766548Z",
    57          "UpdatedAt": "2016-11-03T20:54:12.924766548Z",
    58          "Spec": {
    59              "Name": "secret.json",
    60              "Labels": {
    61                  "env": "dev",
    62                  "rev": "20161102"
    63              },
    64              "Data": null
    65          },
    66          "Digest": "sha256:4212a44b14e94154359569333d3fc6a80f6b9959dfdaff26412f4b2796b1f387",
    67          "SecretSize": 1679
    68      }
    69  ]
    70  
    71  ```
    72  
    73  
    74  ## Related information
    75  
    76  * [secret inspect](secret_inspect.md)
    77  * [secret ls](secret_ls.md)
    78  * [secret rm](secret_rm.md)