diff options
author | Brian Goff <cpuguy83@gmail.com> | 2015-09-23 21:15:23 -0400 |
---|---|---|
committer | Brian Goff <cpuguy83@gmail.com> | 2015-09-23 21:15:23 -0400 |
commit | 40e856041265d6030768286f1b228f042c0f768b (patch) | |
tree | c58e63afb6dd4effd8b92b1ea2a2ad372acbfe1d | |
parent | a51861226058299e0e504f5b512f0f9e2b4c6fb3 (diff) | |
parent | 141e91c4803124bdf55dd45a06998748b0ef5fb2 (diff) | |
download | docker-40e856041265d6030768286f1b228f042c0f768b.tar.gz |
Merge pull request #16415 from HuKeping/dockerinfo
Format output of docker info
-rw-r--r-- | api/client/info.go | 21 | ||||
-rw-r--r-- | docs/reference/commandline/info.md | 35 | ||||
-rw-r--r-- | docs/userguide/labels-custom-metadata.md | 35 | ||||
-rw-r--r-- | pkg/ioutils/fmt.go | 8 |
4 files changed, 57 insertions, 42 deletions
diff --git a/api/client/info.go b/api/client/info.go index eef673303e..ae541dfb4e 100644 --- a/api/client/info.go +++ b/api/client/info.go @@ -53,13 +53,13 @@ func (cli *DockerCli) CmdInfo(args ...string) error { if info.Debug { fmt.Fprintf(cli.out, "Debug mode (server): %v\n", info.Debug) - fmt.Fprintf(cli.out, "File Descriptors: %d\n", info.NFd) - fmt.Fprintf(cli.out, "Goroutines: %d\n", info.NGoroutines) - fmt.Fprintf(cli.out, "System Time: %s\n", info.SystemTime) - fmt.Fprintf(cli.out, "EventsListeners: %d\n", info.NEventsListener) - fmt.Fprintf(cli.out, "Init SHA1: %s\n", info.InitSha1) - fmt.Fprintf(cli.out, "Init Path: %s\n", info.InitPath) - fmt.Fprintf(cli.out, "Docker Root Dir: %s\n", info.DockerRootDir) + fmt.Fprintf(cli.out, " File Descriptors: %d\n", info.NFd) + fmt.Fprintf(cli.out, " Goroutines: %d\n", info.NGoroutines) + fmt.Fprintf(cli.out, " System Time: %s\n", info.SystemTime) + fmt.Fprintf(cli.out, " EventsListeners: %d\n", info.NEventsListener) + fmt.Fprintf(cli.out, " Init SHA1: %s\n", info.InitSha1) + fmt.Fprintf(cli.out, " Init Path: %s\n", info.InitPath) + fmt.Fprintf(cli.out, " Docker Root Dir: %s\n", info.DockerRootDir) } ioutils.FprintfIfNotEmpty(cli.out, "Http Proxy: %s\n", info.HTTPProxy) @@ -73,7 +73,8 @@ func (cli *DockerCli) CmdInfo(args ...string) error { fmt.Fprintf(cli.out, "Registry: %v\n", info.IndexServerAddress) } } - // Only output these warnings if the server supports these features + + // Only output these warnings if the server does not support these features if h, err := httputils.ParseServerHeader(serverResp.header.Get("Server")); err == nil { if h.OS != "windows" { if !info.MemoryLimit { @@ -101,9 +102,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error { } } - if info.ExperimentalBuild { - fmt.Fprintf(cli.out, "Experimental: true\n") - } + ioutils.FprintfIfTrue(cli.out, "Experimental: %v\n", info.ExperimentalBuild) return nil } diff --git a/docs/reference/commandline/info.md b/docs/reference/commandline/info.md index b156696d75..129c2ee6de 100644 --- a/docs/reference/commandline/info.md +++ b/docs/reference/commandline/info.md @@ -26,25 +26,26 @@ For example: Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 545 + Dirperm1 Supported: true Execution Driver: native-0.2 Logging Driver: json-file - Kernel Version: 3.13.0-24-generic - Operating System: Ubuntu 14.04 LTS - CPUs: 1 - Name: prod-server-42 - ID: 7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS - Total Memory: 2 GiB - Debug mode (server): false - Debug mode (client): true - File Descriptors: 10 - Goroutines: 9 - System Time: Tue Mar 10 18:38:57 UTC 2015 - EventsListeners: 0 - Init Path: /usr/bin/docker - Docker Root Dir: /var/lib/docker - Http Proxy: http://test:test@localhost:8080 - Https Proxy: https://test:test@localhost:8080 - No Proxy: 9.81.1.160 + Kernel Version: 3.19.0-22-generic + Operating System: Ubuntu 15.04 + CPUs: 24 + Total Memory: 62.86 GiB + Name: docker + ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S + Debug mode (server): true + File Descriptors: 59 + Goroutines: 159 + System Time: 2015-09-23T14:04:20.699842089+08:00 + EventsListeners: 0 + Init SHA1: + Init Path: /usr/bin/docker + Docker Root Dir: /var/lib/docker + Http Proxy: http://test:test@localhost:8080 + Https Proxy: https://test:test@localhost:8080 + WARNING: No swap limit support Username: svendowideit Registry: [https://index.docker.io/v1/] Labels: diff --git a/docs/userguide/labels-custom-metadata.md b/docs/userguide/labels-custom-metadata.md index 122b87cc59..0bb1d75680 100644 --- a/docs/userguide/labels-custom-metadata.md +++ b/docs/userguide/labels-custom-metadata.md @@ -185,29 +185,36 @@ on how to query labels set on a container. These labels appear as part of the `docker info` output for the daemon: - docker -D info + $ docker -D info Containers: 12 Images: 672 + Engine Version: 1.9.0 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 697 + Dirperm1 Supported: true Execution Driver: native-0.2 Logging Driver: json-file - Kernel Version: 3.13.0-32-generic - Operating System: Ubuntu 14.04.1 LTS - CPUs: 1 - Total Memory: 994.1 MiB - Name: docker.example.com - ID: RC3P:JTCT:32YS:XYSB:YUBG:VFED:AAJZ:W3YW:76XO:D7NN:TEVU:UCRW - Debug mode (server): false - Debug mode (client): true - File Descriptors: 11 - Goroutines: 14 - EventsListeners: 0 - Init Path: /usr/bin/docker - Docker Root Dir: /var/lib/docker + Kernel Version: 3.19.0-22-generic + Operating System: Ubuntu 15.04 + CPUs: 24 + Total Memory: 62.86 GiB + Name: docker + ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S + Debug mode (server): true + File Descriptors: 59 + Goroutines: 159 + System Time: 2015-09-23T14:04:20.699842089+08:00 + EventsListeners: 0 + Init SHA1: + Init Path: /usr/bin/docker + Docker Root Dir: /var/lib/docker + Http Proxy: http://test:test@localhost:8080 + Https Proxy: https://test:test@localhost:8080 WARNING: No swap limit support + Username: svendowideit + Registry: [https://index.docker.io/v1/] Labels: com.example.environment=production com.example.storage=ssd diff --git a/pkg/ioutils/fmt.go b/pkg/ioutils/fmt.go index 801132ff3d..0b04b0ba3e 100644 --- a/pkg/ioutils/fmt.go +++ b/pkg/ioutils/fmt.go @@ -12,3 +12,11 @@ func FprintfIfNotEmpty(w io.Writer, format, value string) (int, error) { } return 0, nil } + +// FprintfIfTrue prints the boolean value if it's true +func FprintfIfTrue(w io.Writer, format string, ok bool) (int, error) { + if ok { + return fmt.Fprintf(w, format, ok) + } + return 0, nil +} |