From 90f2c9cf902a13acca37d8c3fce5ae4c7d874239 Mon Sep 17 00:00:00 2001 From: Patrick Hemmer Date: Thu, 25 Jun 2015 21:25:41 -0400 Subject: [PATCH] add --format flag to `docker version` Signed-off-by: Patrick Hemmer --- docs/reference/commandline/version.md | 26 +++++++++++++++++++++++--- man/docker-version.1.md | 24 ++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/docs/reference/commandline/version.md b/docs/reference/commandline/version.md index a0ae2406af..a976546ef9 100644 --- a/docs/reference/commandline/version.md +++ b/docs/reference/commandline/version.md @@ -15,8 +15,17 @@ weight=1 Show the Docker version information. -Show the Docker version, API version, Go version, Git commit, Build date/time, -and OS/architecture of both Docker client and daemon. Example use: + -f, --format="" Format the output using the given go template + +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. + +Go's [text/template](http://golang.org/pkg/text/template/) package +describes all the details of the format. + +## Examples + +**Default output:** $ docker version Client: @@ -33,4 +42,15 @@ and OS/architecture of both Docker client and daemon. Example use: Go version: go1.4.2 Git commit: f5bae0a Built: Tue Jun 23 17:56:00 UTC 2015 - OS/Arch: linux/amd64 \ No newline at end of file + OS/Arch: linux/amd64 + +**Get server version:** + + $ docker version --format '{{.Server.Version}}' + 1.8.0 + +**Dump raw data:** + + $ docker version --format '{{json .}}' + {"Client":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"amd64","BuildTime":"Tue Jun 23 17:56:00 UTC 2015"},"ServerOK":true,"Server":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"amd64","KernelVersion":"3.13.2-gentoo","BuildTime":"Tue Jun 23 17:56:00 UTC 2015"}} + diff --git a/man/docker-version.1.md b/man/docker-version.1.md index ffdd48e70b..04ae3464f8 100644 --- a/man/docker-version.1.md +++ b/man/docker-version.1.md @@ -6,19 +6,25 @@ docker-version - Show the Docker version information. # SYNOPSIS **docker version** +[**--help**] +[**-f**|**--format**[=*FORMAT*]] # DESCRIPTION This command displays version information for both the Docker client and daemon. # OPTIONS -There are no available options. +**--help** + Print usage statement + +**-f**, **--format**="" + Format the output using the given go template. # EXAMPLES ## Display Docker version information -Here is a sample output: +The default output: $ docker version Client: @@ -36,7 +42,21 @@ Here is a sample output: Git commit: f5bae0a Built: Tue Jun 23 17:56:00 UTC 2015 OS/Arch: linux/amd64 + +Get server version: + + $ docker version --format '{{.Server.Version}}' + 1.8.0 + +Dump raw data: + +To view all available fields, you can use the format `{{json .}}`. + + $ docker version --format '{{json .}}' + {"Client":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"amd64","BuildTime":"Tue Jun 23 17:56:00 UTC 2015"},"ServerOK":true,"Server":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"amd64","KernelVersion":"3.13.2-gentoo","BuildTime":"Tue Jun 23 17:56:00 UTC 2015"}} + # HISTORY June 2014, updated by Sven Dowideit June 2015, updated by John Howard +June 2015, updated by Patrick Hemmer