github.com/docker/docker-ce@v17.12.1-ce-rc2+incompatible/components/cli/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/cli GitHub
     8       repository at https://github.com/docker/cli/. 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 file|-
    20  
    21  Create a secret from a file or STDIN as content
    22  
    23  Options:
    24        --help          Print usage
    25    -l, --label list    Secret labels (default [])
    26  ```
    27  
    28  ## Description
    29  
    30  Creates a secret using standard input or from a file for the secret content. You must run this command on a manager node. 
    31  
    32  For detailed information about using secrets, refer to [manage sensitive data with Docker secrets](https://docs.docker.com/engine/swarm/secrets/).
    33  
    34  ## Examples
    35  
    36  ### Create a secret
    37  
    38  ```bash
    39  $ echo <secret> | docker secret create my_secret -
    40  
    41  onakdyv307se2tl7nl20anokv
    42  
    43  $ docker secret ls
    44  
    45  ID                          NAME                CREATED             UPDATED
    46  onakdyv307se2tl7nl20anokv   my_secret           6 seconds ago       6 seconds ago
    47  ```
    48  
    49  ### Create a secret with a file
    50  
    51  ```bash
    52  $ docker secret create my_secret ./secret.json
    53  
    54  dg426haahpi5ezmkkj5kyl3sn
    55  
    56  $ docker secret ls
    57  
    58  ID                          NAME                CREATED             UPDATED
    59  dg426haahpi5ezmkkj5kyl3sn   my_secret           7 seconds ago       7 seconds ago
    60  ```
    61  
    62  ### Create a secret with labels
    63  
    64  ```bash
    65  $ docker secret create --label env=dev \
    66                         --label rev=20170324 \
    67                         my_secret ./secret.json
    68  
    69  eo7jnzguqgtpdah3cm5srfb97
    70  ```
    71  
    72  ```none
    73  $ docker secret inspect my_secret
    74  
    75  [
    76      {
    77          "ID": "eo7jnzguqgtpdah3cm5srfb97",
    78          "Version": {
    79              "Index": 17
    80          },
    81          "CreatedAt": "2017-03-24T08:15:09.735271783Z",
    82          "UpdatedAt": "2017-03-24T08:15:09.735271783Z",
    83          "Spec": {
    84              "Name": "my_secret",
    85              "Labels": {
    86                  "env": "dev",
    87                  "rev": "20170324"
    88              }
    89          }
    90      }
    91  ]
    92  ```
    93  
    94  
    95  ## Related commands
    96  
    97  * [secret inspect](secret_inspect.md)
    98  * [secret ls](secret_ls.md)
    99  * [secret rm](secret_rm.md)