summaryrefslogtreecommitdiff
path: root/devdocs/docker/engine%2Freference%2Fcommandline%2Fsecret_create%2Findex.html
blob: 5c57bfc9db8a9c8632d2f0e8af49506f5fa9c518 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<h1>docker secret create</h1>  <p><br></p> <p>Create a secret from a file or STDIN as content</p> <p><span class="badge badge-info" data-toggle="tooltip" data-placement="right" title="This command works with the Swarm orchestrator.">Swarm</span> This command works with the Swarm orchestrator.</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker secret create [OPTIONS] SECRET [file|-]
</pre></div> <p>Refer to the <a href="#options">options section</a> for an overview of available <a href="#options"><code class="language-plaintext highlighter-rouge">OPTIONS</code></a> for this command.</p> <h2 id="description">Description</h2> <p name="extended-description">Creates a secret using standard input or from a file for the secret content.</p> <p>For detailed information about using secrets, refer to <a href="../../../swarm/secrets/index">manage sensitive data with Docker secrets</a>.</p> <blockquote> <p><strong>Note</strong></p> <p>This is a cluster management command, and must be executed on a swarm manager node. To learn about managers and workers, refer to the <a href="../../../swarm/index">Swarm mode section</a> in the documentation.</p> </blockquote> <p>For example uses of this command, refer to the <a href="#examples">examples section</a> below.</p> <h2 id="options">Options</h2> <table> <thead> <tr> <td>Name, shorthand</td> <td>Default</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>
<code class="language-plaintext highlighter-rouge">--driver</code> , <code class="language-plaintext highlighter-rouge">-d</code>
</td> <td></td> <td>Secret driver</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--label</code> , <code class="language-plaintext highlighter-rouge">-l</code>
</td> <td></td> <td>Secret labels</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--template-driver</code></td> <td></td> <td>Template driver</td> </tr>  </tbody> </table>  <h2 id="examples">Examples</h2> <h3 id="create-a-secret">Create a secret</h3> <div class="highlight"><pre class="highlight" data-language="">$ printf "my super secret password" | docker secret create my_secret -

onakdyv307se2tl7nl20anokv

$ docker secret ls

ID                          NAME                CREATED             UPDATED
onakdyv307se2tl7nl20anokv   my_secret           6 seconds ago       6 seconds ago
</pre></div> <h3 id="create-a-secret-with-a-file">Create a secret with a file</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker secret create my_secret ./secret.json

dg426haahpi5ezmkkj5kyl3sn

$ docker secret ls

ID                          NAME                CREATED             UPDATED
dg426haahpi5ezmkkj5kyl3sn   my_secret           7 seconds ago       7 seconds ago
</pre></div> <h3 id="create-a-secret-with-labels">Create a secret with labels</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker secret create \
  --label env=dev \
  --label rev=20170324 \
  my_secret ./secret.json

eo7jnzguqgtpdah3cm5srfb97
</pre></div> <div class="highlight"><pre class="highlight" data-language="">$ docker secret inspect my_secret

[
    {
        "ID": "eo7jnzguqgtpdah3cm5srfb97",
        "Version": {
            "Index": 17
        },
        "CreatedAt": "2017-03-24T08:15:09.735271783Z",
        "UpdatedAt": "2017-03-24T08:15:09.735271783Z",
        "Spec": {
            "Name": "my_secret",
            "Labels": {
                "env": "dev",
                "rev": "20170324"
            }
        }
    }
]
</pre></div> <h2 id="parent-command">Parent command</h2> <table> <thead> <tr> <th style="text-align: left">Command</th> <th style="text-align: left">Description</th> </tr> </thead> <tbody> <tr> <td style="text-align: left"><a href="../secret/index">docker secret</a></td> <td style="text-align: left">Manage Docker secrets</td> </tr> </tbody> </table> <h2 id="related-commands">Related commands</h2> <table> <thead> <tr> <td>Command</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td><a href="index">docker secret create</a></td> <td>Create a secret from a file or STDIN as content</td> </tr> <tr> <td><a href="../secret_inspect/index">docker secret inspect</a></td> <td>Display detailed information on one or more secrets</td> </tr> <tr> <td><a href="../secret_ls/index">docker secret ls</a></td> <td>List secrets</td> </tr> <tr> <td><a href="../secret_rm/index">docker secret rm</a></td> <td>Remove one or more secrets</td> </tr> </tbody> </table> <div class="_attribution">
  <p class="_attribution-p">
    &copy; 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
    <a href="https://docs.docker.com/engine/reference/commandline/secret_create/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/secret_create/</a>
  </p>
</div>