github.com/thajeztah/cli@v0.0.0-20240223162942-dc6bfac81a8b/docs/reference/commandline/version.md (about) 1 # version 2 3 <!---MARKER_GEN_START--> 4 Show 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 17 The version command prints the current version number for all independently 18 versioned Docker components. Use the [`--format`](#format) option to customize 19 the output. 20 21 The version command (`docker version`) outputs the version numbers of Docker 22 components, while the `--version` flag (`docker --version`) outputs the version 23 number of the Docker CLI you are using. 24 25 ### Default output 26 27 The default output renders all version information divided into two sections; 28 the `Client` section contains information about the Docker CLI and client 29 components, and the `Server` section contains information about the Docker 30 Engine and components used by the Docker Engine, such as the containerd and runc 31 OCI Runtimes. 32 33 The information shown may differ depending on how you installed Docker and 34 what components are in use. The following example shows the output on a macOS 35 machine running Docker Desktop: 36 37 ```console 38 $ docker version 39 40 Client: 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 49 Server: 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 71 Docker uses a client/server architecture, which allows you to use the Docker CLI 72 on your local machine to control a Docker Engine running on a remote machine, 73 which can be (for example) a machine running in the cloud or inside a virtual machine. 74 75 The following example switches the Docker CLI to use a [context](context.md) 76 named `remote-test-server`, which runs an older version of the Docker Engine 77 on a Linux server: 78 79 ```console 80 $ docker context use remote-test-server 81 remote-test-server 82 83 $ docker version 84 85 Client: 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 94 Server: 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 115 The API version used by the client depends on the Docker Engine that the Docker 116 CLI is connecting with. When connecting with the Docker Engine, the Docker CLI 117 and Docker Engine perform API version negotiation, and select the highest API 118 version that is supported by both the Docker CLI and the Docker Engine. 119 120 For example, if the CLI is connecting with Docker Engine version 19.03, it downgrades 121 to API version 1.40 (refer to the [API version matrix](https://docs.docker.com/engine/api/#api-version-matrix) 122 to learn about the supported API versions for Docker Engine): 123 124 ```console 125 $ docker version --format '{{.Client.APIVersion}}' 126 127 1.40 128 ``` 129 130 Be aware that API version can also be overridden using the `DOCKER_API_VERSION` 131 environment variable, which can be useful for debugging purposes, and disables 132 API version negotiation. The following example illustrates an environment where 133 the `DOCKER_API_VERSION` environment variable is set. Unsetting the environment 134 variable removes the override, and re-enables API version negotiation: 135 136 ```console 137 $ env | grep DOCKER_API_VERSION 138 DOCKER_API_VERSION=1.39 139 140 $ docker version --format '{{.Client.APIVersion}}' 141 1.39 142 143 $ unset DOCKER_API_VERSION 144 $ docker version --format '{{.Client.APIVersion}}' 145 1.42 146 ``` 147 148 ## Examples 149 150 ### <a name="format"></a> Format the output (--format) 151 152 The formatting option (`--format`) pretty-prints the output using a Go template, 153 which allows you to customize the output format, or to obtain specific information 154 from the output. Refer to the [format command and log output](https://docs.docker.com/config/formatting/) 155 page for details of the format. 156 157 ### Get the server version 158 159 ```console 160 $ docker version --format '{{.Server.Version}}' 161 162 23.0.3 163 ``` 164 165 ### Get the client API version 166 167 The following example prints the API version that is used by the client: 168 169 ```console 170 $ docker version --format '{{.Client.APIVersion}}' 171 172 1.42 173 ``` 174 175 The version shown is the API version that is negotiated between the client 176 and the Docker Engine. Refer to [API version and version negotiation](#api-version-and-version-negotiation) 177 above 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 ```