2016-10-27 20:30:32 -04:00
|
|
|
---
|
|
|
|
title: "secret create"
|
|
|
|
description: "The secret create command description and usage"
|
|
|
|
keywords: ["secret, create"]
|
|
|
|
---
|
|
|
|
|
|
|
|
<!-- This file is maintained within the docker/docker Github
|
|
|
|
repository at https://github.com/docker/docker/. Make all
|
|
|
|
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
|
2017-01-06 15:06:02 -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:
|
2016-11-19 20:41:11 -05:00
|
|
|
--help Print usage
|
|
|
|
-l, --label list Secret labels (default [])
|
2016-10-27 20:30:32 -04:00
|
|
|
```
|
|
|
|
|
2016-11-19 20:41:11 -05:00
|
|
|
Creates a secret using standard input or from a file for the secret content. You must run this
|
2016-10-27 20:30:32 -04:00
|
|
|
command on a manager node.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
### Create a secret
|
|
|
|
|
|
|
|
```bash
|
2017-01-06 15:06:02 -05:00
|
|
|
$ echo <secret> | docker secret create my_secret -
|
2016-11-19 20:41:11 -05:00
|
|
|
mhv17xfe3gh6xc4rij5orpfds
|
|
|
|
|
|
|
|
$ docker secret ls
|
|
|
|
ID NAME CREATED UPDATED SIZE
|
2017-01-04 02:13:31 -05:00
|
|
|
mhv17xfe3gh6xc4rij5orpfds my_secret 2016-10-27 23:25:43.909181089 +0000 UTC 2016-10-27 23:25:43.909181089 +0000 UTC 1679
|
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
|
2016-10-27 20:30:32 -04:00
|
|
|
mhv17xfe3gh6xc4rij5orpfds
|
|
|
|
|
|
|
|
$ docker secret ls
|
2016-11-03 17:01:54 -04:00
|
|
|
ID NAME CREATED UPDATED SIZE
|
2017-01-04 02:13:31 -05:00
|
|
|
mhv17xfe3gh6xc4rij5orpfds my_secret 2016-10-27 23:25:43.909181089 +0000 UTC 2016-10-27 23:25:43.909181089 +0000 UTC 1679
|
2016-10-27 20:30:32 -04:00
|
|
|
```
|
|
|
|
|
2016-11-03 17:01:54 -04:00
|
|
|
### Create a secret with labels
|
|
|
|
|
|
|
|
```bash
|
2017-01-06 15:06:02 -05:00
|
|
|
$ docker secret create --label env=dev --label rev=20161102 my_secret ./secret.json
|
2016-11-03 17:01:54 -04:00
|
|
|
jtn7g6aukl5ky7nr9gvwafoxh
|
|
|
|
|
2017-01-04 02:13:31 -05:00
|
|
|
$ docker secret inspect my_secret
|
2016-11-03 17:01:54 -04:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"ID": "jtn7g6aukl5ky7nr9gvwafoxh",
|
|
|
|
"Version": {
|
|
|
|
"Index": 541
|
|
|
|
},
|
|
|
|
"CreatedAt": "2016-11-03T20:54:12.924766548Z",
|
|
|
|
"UpdatedAt": "2016-11-03T20:54:12.924766548Z",
|
|
|
|
"Spec": {
|
2017-01-04 02:13:31 -05:00
|
|
|
"Name": "my_secret",
|
2016-11-03 17:01:54 -04:00
|
|
|
"Labels": {
|
|
|
|
"env": "dev",
|
|
|
|
"rev": "20161102"
|
|
|
|
},
|
|
|
|
"Data": null
|
|
|
|
},
|
|
|
|
"Digest": "sha256:4212a44b14e94154359569333d3fc6a80f6b9959dfdaff26412f4b2796b1f387",
|
|
|
|
"SecretSize": 1679
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2016-10-27 20:30:32 -04:00
|
|
|
## Related information
|
|
|
|
|
|
|
|
* [secret inspect](secret_inspect.md)
|
|
|
|
* [secret ls](secret_ls.md)
|
|
|
|
* [secret rm](secret_rm.md)
|