github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/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  # secret create
     8  
     9  ```Markdown
    10  Usage:  docker secret create [OPTIONS] SECRET [file|-]
    11  
    12  Create a secret from a file or STDIN as content
    13  
    14  Options:
    15    -l, --label list               Secret labels
    16        --template-driver string   Template driver
    17  ```
    18  
    19  ## Description
    20  
    21  Creates a secret using standard input or from a file for the secret content.
    22  
    23  For detailed information about using secrets, refer to [manage sensitive data with Docker secrets](https://docs.docker.com/engine/swarm/secrets/).
    24  
    25  > **Note**
    26  >
    27  > This is a cluster management command, and must be executed on a swarm
    28  > manager node. To learn about managers and workers, refer to the
    29  > [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
    30  > documentation.
    31  
    32  ## Examples
    33  
    34  ### Create a secret
    35  
    36  ```bash
    37  $ printf <secret> | docker secret create my_secret -
    38  
    39  onakdyv307se2tl7nl20anokv
    40  
    41  $ docker secret ls
    42  
    43  ID                          NAME                CREATED             UPDATED
    44  onakdyv307se2tl7nl20anokv   my_secret           6 seconds ago       6 seconds ago
    45  ```
    46  
    47  ### Create a secret with a file
    48  
    49  ```bash
    50  $ docker secret create my_secret ./secret.json
    51  
    52  dg426haahpi5ezmkkj5kyl3sn
    53  
    54  $ docker secret ls
    55  
    56  ID                          NAME                CREATED             UPDATED
    57  dg426haahpi5ezmkkj5kyl3sn   my_secret           7 seconds ago       7 seconds ago
    58  ```
    59  
    60  ### Create a secret with labels
    61  
    62  ```bash
    63  $ docker secret create --label env=dev \
    64                         --label rev=20170324 \
    65                         my_secret ./secret.json
    66  
    67  eo7jnzguqgtpdah3cm5srfb97
    68  ```
    69  
    70  ```bash
    71  $ docker secret inspect my_secret
    72  
    73  [
    74      {
    75          "ID": "eo7jnzguqgtpdah3cm5srfb97",
    76          "Version": {
    77              "Index": 17
    78          },
    79          "CreatedAt": "2017-03-24T08:15:09.735271783Z",
    80          "UpdatedAt": "2017-03-24T08:15:09.735271783Z",
    81          "Spec": {
    82              "Name": "my_secret",
    83              "Labels": {
    84                  "env": "dev",
    85                  "rev": "20170324"
    86              }
    87          }
    88      }
    89  ]
    90  ```
    91  
    92  
    93  ## Related commands
    94  
    95  * [secret inspect](secret_inspect.md)
    96  * [secret ls](secret_ls.md)
    97  * [secret rm](secret_rm.md)