github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/docs/reference/commandline/secret_ls.md (about)

     1  ---
     2  title: "secret ls"
     3  description: "The secret ls command description and usage"
     4  keywords: ["secret, ls"]
     5  ---
     6  
     7  # secret ls
     8  
     9  ```Markdown
    10  Usage:  docker secret ls [OPTIONS]
    11  
    12  List secrets
    13  
    14  Aliases:
    15    ls, list
    16  
    17  Options:
    18    -f, --filter filter   Filter output based on conditions provided
    19        --format string   Pretty-print secrets using a Go template
    20        --help            Print usage
    21    -q, --quiet           Only display IDs
    22  ```
    23  
    24  ## Description
    25  
    26  Run this command on a manager node to list the secrets in the swarm.
    27  
    28  For detailed information about using secrets, refer to [manage sensitive data with Docker secrets](https://docs.docker.com/engine/swarm/secrets/).
    29  
    30  > **Note**
    31  >
    32  > This is a cluster management command, and must be executed on a swarm
    33  > manager node. To learn about managers and workers, refer to the
    34  > [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
    35  > documentation.
    36  
    37  ## Examples
    38  
    39  ```bash
    40  $ docker secret ls
    41  
    42  ID                          NAME                        CREATED             UPDATED
    43  6697bflskwj1998km1gnnjr38   q5s5570vtvnimefos1fyeo2u2   6 weeks ago         6 weeks ago
    44  9u9hk4br2ej0wgngkga6rp4hq   my_secret                   5 weeks ago         5 weeks ago
    45  mem02h8n73mybpgqjf0kfi1n0   test_secret                 3 seconds ago       3 seconds ago
    46  ```
    47  
    48  ### Filtering
    49  
    50  The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there is more
    51  than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
    52  
    53  The currently supported filters are:
    54  
    55  - [id](#id) (secret's ID)
    56  - [label](#label) (`label=<key>` or `label=<key>=<value>`)
    57  - [name](#name) (secret's name)
    58  
    59  #### id
    60  
    61  The `id` filter matches all or prefix of a secret's id.
    62  
    63  ```bash
    64  $ docker secret ls -f "id=6697bflskwj1998km1gnnjr38"
    65  
    66  ID                          NAME                        CREATED             UPDATED
    67  6697bflskwj1998km1gnnjr38   q5s5570vtvnimefos1fyeo2u2   6 weeks ago         6 weeks ago
    68  ```
    69  
    70  #### label
    71  
    72  The `label` filter matches secrets based on the presence of a `label` alone or
    73  a `label` and a value.
    74  
    75  The following filter matches all secrets with a `project` label regardless of
    76  its value:
    77  
    78  ```bash
    79  $ docker secret ls --filter label=project
    80  
    81  ID                          NAME                        CREATED             UPDATED
    82  mem02h8n73mybpgqjf0kfi1n0   test_secret                 About an hour ago   About an hour ago
    83  ```
    84  
    85  The following filter matches only services with the `project` label with the
    86  `project-a` value.
    87  
    88  ```bash
    89  $ docker service ls --filter label=project=test
    90  
    91  ID                          NAME                        CREATED             UPDATED
    92  mem02h8n73mybpgqjf0kfi1n0   test_secret                 About an hour ago   About an hour ago
    93  ```
    94  
    95  #### name
    96  
    97  The `name` filter matches on all or prefix of a secret's name.
    98  
    99  The following filter matches secret with a name containing a prefix of `test`.
   100  
   101  ```bash
   102  $ docker secret ls --filter name=test_secret
   103  
   104  ID                          NAME                        CREATED             UPDATED
   105  mem02h8n73mybpgqjf0kfi1n0   test_secret                 About an hour ago   About an hour ago
   106  ```
   107  
   108  ### Format the output
   109  
   110  The formatting option (`--format`) pretty prints secrets output
   111  using a Go template.
   112  
   113  Valid placeholders for the Go template are listed below:
   114  
   115  | Placeholder  | Description                                                                          |
   116  | ------------ | ------------------------------------------------------------------------------------ |
   117  | `.ID`        | Secret ID                                                                            |
   118  | `.Name`      | Secret name                                                                          |
   119  | `.CreatedAt` | Time when the secret was created                                                     |
   120  | `.UpdatedAt` | Time when the secret was updated                                                     |
   121  | `.Labels`    | All labels assigned to the secret                                                    |
   122  | `.Label`     | Value of a specific label for this secret. For example `{{.Label "secret.ssh.key"}}` |
   123  
   124  When using the `--format` option, the `secret ls` command will either
   125  output the data exactly as the template declares or, when using the
   126  `table` directive, will include column headers as well.
   127  
   128  The following example uses a template without headers and outputs the
   129  `ID` and `Name` entries separated by a colon (`:`) for all images:
   130  
   131  ```bash
   132  $ docker secret ls --format "{{.ID}}: {{.Name}}"
   133  
   134  77af4d6b9913: secret-1
   135  b6fa739cedf5: secret-2
   136  78a85c484f71: secret-3
   137  ```
   138  
   139  To list all secrets with their name and created date in a table format you
   140  can use:
   141  
   142  ```bash
   143  $ docker secret ls --format "table {{.ID}}\t{{.Name}}\t{{.CreatedAt}}"
   144  
   145  ID                  NAME                      CREATED
   146  77af4d6b9913        secret-1                  5 minutes ago
   147  b6fa739cedf5        secret-2                  3 hours ago
   148  78a85c484f71        secret-3                  10 days ago
   149  ```
   150  
   151  ## Related commands
   152  
   153  * [secret create](secret_create.md)
   154  * [secret inspect](secret_inspect.md)
   155  * [secret rm](secret_rm.md)