...
1# version
2
3<!---MARKER_GEN_START-->
4Show the Docker version information
5
6### Options
7
8| Name | Type | Default | Description |
9|:---------------------------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
10| [`-f`](#format), [`--format`](#format) | `string` | | Format output using a custom template:<br>'json': Print in JSON format<br>'TEMPLATE': Print output using the given Go template.<br>Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates |
11
12
13<!---MARKER_GEN_END-->
14
15## Description
16
17The version command prints the current version number for all independently
18versioned Docker components. Use the [`--format`](#format) option to customize
19the output.
20
21The version command (`docker version`) outputs the version numbers of Docker
22components, while the `--version` flag (`docker --version`) outputs the version
23number of the Docker CLI you are using.
24
25### Default output
26
27The default output renders all version information divided into two sections;
28the `Client` section contains information about the Docker CLI and client
29components, and the `Server` section contains information about the Docker
30Engine and components used by the Docker Engine, such as the containerd and runc
31OCI Runtimes.
32
33The information shown may differ depending on how you installed Docker and
34what components are in use. The following example shows the output on a macOS
35machine running Docker Desktop:
36
37```console
38$ docker version
39
40Client: Docker Engine - Community
41 Version: 23.0.3
42 API version: 1.42
43 Go version: go1.19.7
44 Git commit: 3e7cbfd
45 Built: Tue Apr 4 22:05:41 2023
46 OS/Arch: darwin/amd64
47 Context: default
48
49Server: Docker Desktop 4.19.0 (12345)
50 Engine:
51 Version: 23.0.3
52 API version: 1.42 (minimum version 1.12)
53 Go version: go1.19.7
54 Git commit: 59118bf
55 Built: Tue Apr 4 22:05:41 2023
56 OS/Arch: linux/amd64
57 Experimental: false
58 containerd:
59 Version: 1.6.20
60 GitCommit: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
61 runc:
62 Version: 1.1.5
63 GitCommit: v1.1.5-0-gf19387a
64 docker-init:
65 Version: 0.19.0
66 GitCommit: de40ad0
67```
68
69### Client and server versions
70
71Docker uses a client/server architecture, which allows you to use the Docker CLI
72on your local machine to control a Docker Engine running on a remote machine,
73which can be (for example) a machine running in the cloud or inside a virtual machine.
74
75The following example switches the Docker CLI to use a [context](context.md)
76named `remote-test-server`, which runs an older version of the Docker Engine
77on a Linux server:
78
79```console
80$ docker context use remote-test-server
81remote-test-server
82
83$ docker version
84
85Client: Docker Engine - Community
86 Version: 23.0.3
87 API version: 1.40 (downgraded from 1.42)
88 Go version: go1.19.7
89 Git commit: 3e7cbfd
90 Built: Tue Apr 4 22:05:41 2023
91 OS/Arch: darwin/amd64
92 Context: remote-test-server
93
94Server: Docker Engine - Community
95 Engine:
96 Version: 19.03.8
97 API version: 1.40 (minimum version 1.12)
98 Go version: go1.12.17
99 Git commit: afacb8b
100 Built: Wed Mar 11 01:29:16 2020
101 OS/Arch: linux/amd64
102 containerd:
103 Version: v1.2.13
104 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
105 runc:
106 Version: 1.0.0-rc10
107 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
108 docker-init:
109 Version: 0.18.0
110 GitCommit: fec3683
111```
112
113### API version and version negotiation
114
115The API version used by the client depends on the Docker Engine that the Docker
116CLI is connecting with. When connecting with the Docker Engine, the Docker CLI
117and Docker Engine perform API version negotiation, and select the highest API
118version that is supported by both the Docker CLI and the Docker Engine.
119
120For example, if the CLI is connecting with Docker Engine version 19.03, it downgrades
121to API version 1.40 (refer to the [API version matrix](https://docs.docker.com/engine/api/#api-version-matrix)
122to learn about the supported API versions for Docker Engine):
123
124```console
125$ docker version --format '{{.Client.APIVersion}}'
126
1271.40
128```
129
130Be aware that API version can also be overridden using the `DOCKER_API_VERSION`
131environment variable, which can be useful for debugging purposes, and disables
132API version negotiation. The following example illustrates an environment where
133the `DOCKER_API_VERSION` environment variable is set. Unsetting the environment
134variable removes the override, and re-enables API version negotiation:
135
136```console
137$ env | grep DOCKER_API_VERSION
138DOCKER_API_VERSION=1.39
139
140$ docker version --format '{{.Client.APIVersion}}'
1411.39
142
143$ unset DOCKER_API_VERSION
144$ docker version --format '{{.Client.APIVersion}}'
1451.42
146```
147
148## Examples
149
150### <a name="format"></a> Format the output (--format)
151
152The formatting option (`--format`) pretty-prints the output using a Go template,
153which allows you to customize the output format, or to obtain specific information
154from the output. Refer to the [format command and log output](https://docs.docker.com/config/formatting/)
155page for details of the format.
156
157### Get the server version
158
159```console
160$ docker version --format '{{.Server.Version}}'
161
16223.0.3
163```
164
165### Get the client API version
166
167The following example prints the API version that is used by the client:
168
169```console
170$ docker version --format '{{.Client.APIVersion}}'
171
1721.42
173```
174
175The version shown is the API version that is negotiated between the client
176and the Docker Engine. Refer to [API version and version negotiation](#api-version-and-version-negotiation)
177above for more information.
178
179### Dump raw JSON data
180
181```console
182$ docker version --format '{{json .}}'
183
184{"Client":"Version":"23.0.3","ApiVersion":"1.42", ...}
185```
View as plain text