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
53
54
55
56
57
58
59
60
61
62
63
64
|
<h1>docker version</h1> <p><br></p> <p>Show the Docker version information</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker version [OPTIONS]
</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">By default, this will render all version information in an easy to read layout. If a format is specified, the given template will be executed instead.</p> <p>Go’s <a href="https://golang.org/pkg/text/template/">text/template</a> package describes all the details of the format.</p> <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">--format</code> , <code class="language-plaintext highlighter-rouge">-f</code>
</td> <td></td> <td>Format the output using the given Go template</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--kubeconfig</code></td> <td></td> <td>
<a href="../../../deprecated/index" target="_blank" rel="noopener" class="_"><span class="badge badge-danger" data-toggle="tooltip" title="Read the deprecation reference (in a new window).">deprecated</span></a><span class="badge badge-info" data-toggle="tooltip" title="This option works for the Kubernetes orchestrator.">Kubernetes</span><br>Kubernetes config file</td> </tr> </tbody> </table> <h2 id="examples">Examples</h2> <h3 id="default-output">Default output</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker version
Client:
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:21:11 2020
OS/Arch: darwin/amd64
Context: default
Experimental: true
Server:
Engine:
Version: 19.03.8
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:29:16 2020
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: v1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
</pre></div> <h3 id="get-the-server-version">Get the server version</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker version --format '{{.Server.Version}}'
19.03.8
</pre></div> <h3 id="dump-raw-json-data">Dump raw JSON data</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker version --format '{{json .}}'
{"Client":{"Platform":{"Name":"Docker Engine - Community"},"Version":"19.03.8","ApiVersion":"1.40","DefaultAPIVersion":"1.40","GitCommit":"afacb8b","GoVersion":"go1.12.17","Os":"darwin","Arch":"amd64","BuildTime":"Wed Mar 11 01:21:11 2020","Experimental":true},"Server":{"Platform":{"Name":"Docker Engine - Community"},"Components":[{"Name":"Engine","Version":"19.03.8","Details":{"ApiVersion":"1.40","Arch":"amd64","BuildTime":"Wed Mar 11 01:29:16 2020","Experimental":"true","GitCommit":"afacb8b","GoVersion":"go1.12.17","KernelVersion":"4.19.76-linuxkit","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"containerd","Version":"v1.2.13","Details":{"GitCommit":"7ad184331fa3e55e52b890ea95e65ba581ae3429"}},{"Name":"runc","Version":"1.0.0-rc10","Details":{"GitCommit":"dc9208a3303feef5b3839f4323d9beb36df0a9dd"}},{"Name":"docker-init","Version":"0.18.0","Details":{"GitCommit":"fec3683"}}],"Version":"19.03.8","ApiVersion":"1.40","MinAPIVersion":"1.12","GitCommit":"afacb8b","GoVersion":"go1.12.17","Os":"linux","Arch":"amd64","KernelVersion":"4.19.76-linuxkit","Experimental":true,"BuildTime":"2020-03-11T01:29:16.000000000+00:00"}}
</pre></div> <h3 id="print-the-current-context">Print the current context</h3> <p>The following example prints the currently used <a href="../context/index"><code class="language-plaintext highlighter-rouge">docker context</code></a>:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker version --format='{{.Client.Context}}'
default
</pre></div> <p>As an example, this output can be used to dynamically change your shell prompt to indicate your active context. The example below illustrates how this output could be used when using Bash as your shell.</p> <p>Declare a function to obtain the current context in your <code class="language-plaintext highlighter-rouge">~/.bashrc</code>, and set this command as your <code class="language-plaintext highlighter-rouge">PROMPT_COMMAND</code></p> <div class="highlight"><pre class="highlight" data-language="">function docker_context_prompt() {
PS1="context: $(docker version --format='{{.Client.Context}}')> "
}
PROMPT_COMMAND=docker_context_prompt
</pre></div> <p>After reloading the <code class="language-plaintext highlighter-rouge">~/.bashrc</code>, the prompt now shows the currently selected <code class="language-plaintext highlighter-rouge">docker context</code>:</p> <div class="highlight"><pre class="highlight" data-language="">$ source ~/.bashrc
context: default> docker context create --docker host=unix:///var/run/docker.sock my-context
my-context
Successfully created context "my-context"
context: default> docker context use my-context
my-context
Current context is now "my-context"
context: my-context> docker context use default
default
Current context is now "default"
context: default>
</pre></div> <p>Refer to the <a href="../context/index"><code class="language-plaintext highlighter-rouge">docker context</code> section</a> in the command line reference for more information about <code class="language-plaintext highlighter-rouge">docker context</code>.</p> <div class="_attribution">
<p class="_attribution-p">
© 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/version/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/version/</a>
</p>
</div>
|