github.com/yogeshlonkar/moby@v1.13.2-0.20201203103638-c0b64beaea94/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 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  mhv17xfe3gh6xc4rij5orpfds
    41  
    42  $ docker secret ls
    43  ID                          NAME                    CREATED                                   UPDATED                                   SIZE
    44  mhv17xfe3gh6xc4rij5orpfds   my_secret               2016-10-27 23:25:43.909181089 +0000 UTC   2016-10-27 23:25:43.909181089 +0000 UTC   1679
    45  ```
    46  
    47  ### Create a secret with a file
    48  
    49  ```bash
    50  $ docker secret create my_secret ./secret.json
    51  
    52  mhv17xfe3gh6xc4rij5orpfds
    53  
    54  $ docker secret ls
    55  
    56  ID                          NAME                    CREATED                                   UPDATED                                   SIZE
    57  mhv17xfe3gh6xc4rij5orpfds   my_secret               2016-10-27 23:25:43.909181089 +0000 UTC   2016-10-27 23:25:43.909181089 +0000 UTC   1679
    58  ```
    59  
    60  ### Create a secret with labels
    61  
    62  ```bash
    63  $ docker secret create --label env=dev \
    64                         --label rev=20161102 \
    65                         my_secret ./secret.json
    66  
    67  jtn7g6aukl5ky7nr9gvwafoxh
    68  ```
    69  
    70  ```none
    71  $ docker secret inspect my_secret
    72  
    73  [
    74      {
    75          "ID": "jtn7g6aukl5ky7nr9gvwafoxh",
    76          "Version": {
    77              "Index": 541
    78          },
    79          "CreatedAt": "2016-11-03T20:54:12.924766548Z",
    80          "UpdatedAt": "2016-11-03T20:54:12.924766548Z",
    81          "Spec": {
    82              "Name": "my_secret",
    83              "Labels": {
    84                  "env": "dev",
    85                  "rev": "20161102"
    86              },
    87              "Data": null
    88          },
    89          "Digest": "sha256:4212a44b14e94154359569333d3fc6a80f6b9959dfdaff26412f4b2796b1f387",
    90          "SecretSize": 1679
    91      }
    92  ]
    93  ```
    94  
    95  
    96  ## Related commands
    97  
    98  * [secret inspect](secret_inspect.md)
    99  * [secret ls](secret_ls.md)
   100  * [secret rm](secret_rm.md)