Docker - docker secret create command

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

The docker secret create command can be used to create a secret. In this example, a secret named my_secret is created.

echo foo | docker secret create my_secret -

 

The docker secret inspect commands will return something like this.

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

 

You can define labels, like this.

echo foo | docker secret create --label foo=bar my_secret -

 

The docker secret inspect commands will return something like this.

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

 




Did you find this article helpful?

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

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





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