github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/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  ```console
    37  $ printf "my super secret password" | 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  ```console
    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  ### <a name="label"></a> Create a secret with labels (--label)
    61  
    62  ```console
    63  $ docker secret create \
    64    --label env=dev \
    65    --label rev=20170324 \
    66    my_secret ./secret.json
    67  
    68  eo7jnzguqgtpdah3cm5srfb97
    69  ```
    70  
    71  ```console
    72  $ docker secret inspect my_secret
    73  
    74  [
    75      {
    76          "ID": "eo7jnzguqgtpdah3cm5srfb97",
    77          "Version": {
    78              "Index": 17
    79          },
    80          "CreatedAt": "2017-03-24T08:15:09.735271783Z",
    81          "UpdatedAt": "2017-03-24T08:15:09.735271783Z",
    82          "Spec": {
    83              "Name": "my_secret",
    84              "Labels": {
    85                  "env": "dev",
    86                  "rev": "20170324"
    87              }
    88          }
    89      }
    90  ]
    91  ```
    92  
    93  
    94  ## Related commands
    95  
    96  * [secret inspect](secret_inspect.md)
    97  * [secret ls](secret_ls.md)
    98  * [secret rm](secret_rm.md)