Bootstrap FreeKB - Docker - list secrets using REST API
Docker - list secrets using REST API

Updated:   |  Docker articles

A secret is a file that contains sensitive data, such as a password.

You will need an auth_token before you can list secrets using curl. 

The following curl command can be used to list every secret. 

curl -k -H "Authorization: Bearer $auth_token" -H 'Accept: application/json' https://hostname:port/secrets

 

Or you can list a single secret by including the id of the secret.

curl -k -H "Authorization: Bearer $auth_token" -H 'Accept: application/json' https://hostname:port/secrets/zt7b37icxabcgz123tnjudjn6

 

Or the name of the secret.

curl -k -H "Authorization: Bearer $auth_token" -H 'Accept: application/json' https://hostname:port/secrets/my_secret

 

If the secret exists, something like this will be displayed.

{
 "ID":"pp6d206pqk28cj12kjv36l2v7 "
 "Version":{
            "Index":16114223
           }
 "CreatedAt":"2019-03-11T18:16:09.317112631Z"
 "UpdatedAt":"2019-03-11T18:16:09.317112631Z"
 "Spec":{
         "Name":"my_secret"
         "Labels":{}
        }
}

 

If the secret does not exist, this will be displayed.

{
 "message":"Error: No such secret: my_secret"
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 3dd755 in the box below so that we can be sure you are a human.