2016-10-27 20:30:32 -04:00
|
|
|
---
|
|
|
|
title: "secret create"
|
|
|
|
description: "The secret create command description and usage"
|
|
|
|
keywords: ["secret, create"]
|
|
|
|
---
|
|
|
|
|
|
|
|
# secret create
|
|
|
|
|
|
|
|
```Markdown
|
2018-02-21 13:45:34 -05:00
|
|
|
Usage: docker secret create [OPTIONS] SECRET [file|-]
|
2016-11-19 20:41:11 -05:00
|
|
|
|
|
|
|
Create a secret from a file or STDIN as content
|
2016-10-27 20:30:32 -04:00
|
|
|
|
2016-11-03 17:01:54 -04:00
|
|
|
Options:
|
2018-02-21 13:45:34 -05:00
|
|
|
-l, --label list Secret labels
|
|
|
|
--template-driver string Template driver
|
2016-10-27 20:30:32 -04:00
|
|
|
```
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Description
|
|
|
|
|
2018-12-23 06:27:52 -05:00
|
|
|
Creates a secret using standard input or from a file for the secret content.
|
2017-03-17 02:51:48 -04:00
|
|
|
|
|
|
|
For detailed information about using secrets, refer to [manage sensitive data with Docker secrets](https://docs.docker.com/engine/swarm/secrets/).
|
2016-10-27 20:30:32 -04:00
|
|
|
|
2018-12-23 06:27:52 -05:00
|
|
|
> **Note**: This is a cluster management command, and must be executed on a swarm
|
|
|
|
> manager node. To learn about managers and workers, refer to the [Swarm mode
|
|
|
|
> section](https://docs.docker.com/engine/swarm/) in the documentation.
|
|
|
|
|
2016-10-27 20:30:32 -04:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
### Create a secret
|
|
|
|
|
|
|
|
```bash
|
2018-04-02 18:15:19 -04:00
|
|
|
$ printf <secret> | docker secret create my_secret -
|
2017-03-24 04:34:03 -04:00
|
|
|
|
|
|
|
onakdyv307se2tl7nl20anokv
|
2016-11-19 20:41:11 -05:00
|
|
|
|
|
|
|
$ docker secret ls
|
2017-03-24 04:34:03 -04:00
|
|
|
|
|
|
|
ID NAME CREATED UPDATED
|
|
|
|
onakdyv307se2tl7nl20anokv my_secret 6 seconds ago 6 seconds ago
|
2016-11-19 20:41:11 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
### Create a secret with a file
|
|
|
|
|
|
|
|
```bash
|
2017-01-06 15:06:02 -05:00
|
|
|
$ docker secret create my_secret ./secret.json
|
2017-02-07 18:42:48 -05:00
|
|
|
|
2017-03-24 04:34:03 -04:00
|
|
|
dg426haahpi5ezmkkj5kyl3sn
|
2016-10-27 20:30:32 -04:00
|
|
|
|
|
|
|
$ docker secret ls
|
2017-02-07 18:42:48 -05:00
|
|
|
|
2017-03-24 04:34:03 -04:00
|
|
|
ID NAME CREATED UPDATED
|
|
|
|
dg426haahpi5ezmkkj5kyl3sn my_secret 7 seconds ago 7 seconds ago
|
2016-10-27 20:30:32 -04:00
|
|
|
```
|
|
|
|
|
2016-11-03 17:01:54 -04:00
|
|
|
### Create a secret with labels
|
|
|
|
|
|
|
|
```bash
|
2017-02-07 18:42:48 -05:00
|
|
|
$ docker secret create --label env=dev \
|
2017-03-24 04:34:03 -04:00
|
|
|
--label rev=20170324 \
|
2017-02-07 18:42:48 -05:00
|
|
|
my_secret ./secret.json
|
|
|
|
|
2017-03-24 04:34:03 -04:00
|
|
|
eo7jnzguqgtpdah3cm5srfb97
|
2017-02-07 18:42:48 -05:00
|
|
|
```
|
2016-11-03 17:01:54 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
```none
|
2017-01-04 02:13:31 -05:00
|
|
|
$ docker secret inspect my_secret
|
2017-02-07 18:42:48 -05:00
|
|
|
|
2016-11-03 17:01:54 -04:00
|
|
|
[
|
|
|
|
{
|
2017-03-24 04:34:03 -04:00
|
|
|
"ID": "eo7jnzguqgtpdah3cm5srfb97",
|
2016-11-03 17:01:54 -04:00
|
|
|
"Version": {
|
2017-03-24 04:34:03 -04:00
|
|
|
"Index": 17
|
2016-11-03 17:01:54 -04:00
|
|
|
},
|
2017-03-24 04:34:03 -04:00
|
|
|
"CreatedAt": "2017-03-24T08:15:09.735271783Z",
|
|
|
|
"UpdatedAt": "2017-03-24T08:15:09.735271783Z",
|
2016-11-03 17:01:54 -04:00
|
|
|
"Spec": {
|
2017-01-04 02:13:31 -05:00
|
|
|
"Name": "my_secret",
|
2016-11-03 17:01:54 -04:00
|
|
|
"Labels": {
|
|
|
|
"env": "dev",
|
2017-03-24 04:34:03 -04:00
|
|
|
"rev": "20170324"
|
|
|
|
}
|
|
|
|
}
|
2016-11-03 17:01:54 -04:00
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Related commands
|
2016-10-27 20:30:32 -04:00
|
|
|
|
|
|
|
* [secret inspect](secret_inspect.md)
|
|
|
|
* [secret ls](secret_ls.md)
|
|
|
|
* [secret rm](secret_rm.md)
|