docs: reference: version: improve description

Move the "default output" section into the description, and
describe the section that can be found in the output.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 99bb525f98)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-05-01 14:00:56 +02:00
parent 9835d5d33a
commit 0b421dc050
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 77 additions and 15 deletions

View File

@ -19,30 +19,84 @@ Options:
## Description ## Description
By default, this will render all version information in an easy to read The version command prints the current version number for all independently
layout. If a format is specified, the given template will be executed instead. versioned Docker components. Use the [`--format`](#format) option to customize
the output.
Go's [text/template](https://golang.org/pkg/text/template/) package The version command (`docker version`) outputs the version numbers of Docker
describes all the details of the format. components, while the `--version` flag (`docker --version`) outputs the version
number of the Docker CLI you are using.
## Examples
### Default output ### Default output
The default output renders all version information divided into two sections;
the "Client" section contains information about the Docker CLI and client
components, and the "Server" section contains information about the Docker
Engine and components used by the Engine, such as the "Containerd" and "Runc"
OCI Runtimes.
The information shown may differ depending on how you installed Docker and
what components are in use. The following example shows the output on a macOS
machine running Docker Desktop:
```console ```console
$ docker version $ docker version
Client: Client:
Version: 19.03.8 Version: 20.10.16
API version: 1.40 API version: 1.41
Go version: go1.12.17 Go version: go1.17.10
Git commit: afacb8b Git commit: aa7e414
Built: Wed Mar 11 01:21:11 2020 Built: Thu May 12 09:17:28 2022
OS/Arch: darwin/amd64 OS/Arch: darwin/amd64
Context: default Context: default
Experimental: true
Server: Server: Docker Desktop 4.8.2 (77141)
Engine:
Version: 20.10.16
API version: 1.41 (minimum version 1.12)
Go version: go1.17.10
Git commit: f756502
Built: Thu May 12 09:15:33 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.4
GitCommit: 212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
runc:
Version: 1.1.1
GitCommit: v1.1.1-0-g52de29d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
```
### Client and server versions
Docker uses a client/server architecture, which allows you to use the Docker CLI
on your local machine to control a Docker Engine running on a remote machine,
which can be (for example) a machine running in the Cloud or inside a Virtual Machine.
The following example switches the Docker CLI to use a [context](context.md)
named "remote-test-server", which runs an older version of the Docker Engine
on a Linux server:
```console
$ docker context use remote-test-server
remote-test-server
$ docker version
Client:
Version: 20.10.16
API version: 1.40 (downgraded from 1.41)
Go version: go1.17.10
Git commit: aa7e414
Built: Thu May 12 09:17:28 2022
OS/Arch: darwin/amd64
Context: remote-test-server
Server: Docker Engine - Community
Engine: Engine:
Version: 19.03.8 Version: 19.03.8
API version: 1.40 (minimum version 1.12) API version: 1.40 (minimum version 1.12)
@ -50,7 +104,6 @@ Server:
Git commit: afacb8b Git commit: afacb8b
Built: Wed Mar 11 01:29:16 2020 Built: Wed Mar 11 01:29:16 2020
OS/Arch: linux/amd64 OS/Arch: linux/amd64
Experimental: true
containerd: containerd:
Version: v1.2.13 Version: v1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
@ -62,12 +115,21 @@ Server:
GitCommit: fec3683 GitCommit: fec3683
``` ```
## Examples
### <a name=format></a> Format the output (--format)
The formatting option (`--format`) pretty-prints the output using a Go template,
which allows you to customize the output format, or to obtain specific information
from the output. Refer to the [format command and log output](https://docs.docker.com/config/formatting/)
page for details of the format.
### Get the server version ### Get the server version
```console ```console
$ docker version --format '{{.Server.Version}}' $ docker version --format '{{.Server.Version}}'
19.03.8 20.10.16
``` ```
### Dump raw JSON data ### Dump raw JSON data