2016-10-27 20:30:32 -04:00
|
|
|
---
|
|
|
|
title: "secret create"
|
|
|
|
description: "The secret create command description and usage"
|
|
|
|
keywords: ["secret, create"]
|
|
|
|
---
|
|
|
|
|
2017-10-04 13:03:55 -04:00
|
|
|
<!-- This file is maintained within the docker/cli GitHub
|
2017-07-28 13:28:23 -04:00
|
|
|
repository at https://github.com/docker/cli/. Make all
|
2016-10-27 20:30:32 -04:00
|
|
|
pull requests against that repo. If you see this file in
|
|
|
|
another repository, consider it read-only there, as it will
|
|
|
|
periodically be overwritten by the definitive file. Pull
|
|
|
|
requests which include edits to this file in other repositories
|
|
|
|
will be rejected.
|
|
|
|
-->
|
|
|
|
|
|
|
|
# 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-04-02 18:15:19 -04:00
|
|
|
Creates a secret using standard input or from a file for the secret content. You must run this command on a manager node.
|
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
|
|
|
|
|
|
|
## 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)
|