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