1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/docs/reference/commandline/secret_create.md
Yong Tang c6f0b7f448 Add --file flag for docker secret create command
This fix tries to address the issue raised in 28581 and 28927
where it is not possible to create a secret from a file (only
through STDIN).

This fix add a flag `--file` to `docker secret create` so that
it is possible to create a secret from a file with:
```
docker secret create --file secret.in secret.name
```

or
```
echo TEST | docker secret create --file - secret.name
```

Related docs has been updated.

An integration test has been added to cover the changes.

This fix fixes 28581.
This fix is related to 28927.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-12-13 07:35:45 -08:00

2.6 KiB

title description keywords
secret create The secret create command description and usage
secret, create

secret create

Usage:	docker secret create [OPTIONS] SECRET

Create a secret from a file or STDIN as content

Options:
  -f, --file string   Read from a file or STDIN ('-')
      --help          Print usage
  -l, --label list    Secret labels (default [])

Creates a secret using standard input or from a file for the secret content. You must run this command on a manager node.

Examples

Create a secret

$ cat secret.json | docker secret create -f - secret.json
mhv17xfe3gh6xc4rij5orpfds

$ docker secret ls
ID                          NAME                    CREATED                                   UPDATED                                   SIZE
mhv17xfe3gh6xc4rij5orpfds   secret.json             2016-10-27 23:25:43.909181089 +0000 UTC   2016-10-27 23:25:43.909181089 +0000 UTC   1679

Create a secret with a file

$ docker secret create --file secret.in secret.json
mhv17xfe3gh6xc4rij5orpfds

$ docker secret ls
ID                          NAME                    CREATED                                   UPDATED                                   SIZE
mhv17xfe3gh6xc4rij5orpfds   secret.json             2016-10-27 23:25:43.909181089 +0000 UTC   2016-10-27 23:25:43.909181089 +0000 UTC   1679

Create a secret with labels

$ cat secret.json | docker secret create secret.json -f - --label env=dev --label rev=20161102
jtn7g6aukl5ky7nr9gvwafoxh

$ docker secret inspect secret.json
[
    {
        "ID": "jtn7g6aukl5ky7nr9gvwafoxh",
        "Version": {
            "Index": 541
        },
        "CreatedAt": "2016-11-03T20:54:12.924766548Z",
        "UpdatedAt": "2016-11-03T20:54:12.924766548Z",
        "Spec": {
            "Name": "secret.json",
            "Labels": {
                "env": "dev",
                "rev": "20161102"
            },
            "Data": null
        },
        "Digest": "sha256:4212a44b14e94154359569333d3fc6a80f6b9959dfdaff26412f4b2796b1f387",
        "SecretSize": 1679
    }
]