From eb714f7c0e8375912e2ddc8df74b5c06d4a375d4 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 23 Jan 2019 14:26:12 +0000 Subject: [PATCH 1/5] Add unit test for `formatInfo`. Signed-off-by: Ian Campbell --- cli/command/system/info_test.go | 37 ++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/cli/command/system/info_test.go b/cli/command/system/info_test.go index 942a645b2e02..fa1a957f8b73 100644 --- a/cli/command/system/info_test.go +++ b/cli/command/system/info_test.go @@ -21,8 +21,10 @@ func base64Decode(val string) []byte { return decoded } +const sampleID = "EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX" + var sampleInfoNoSwarm = types.Info{ - ID: "EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX", + ID: sampleID, Containers: 0, ContainersRunning: 0, ContainersPaused: 0, @@ -263,3 +265,36 @@ func TestPrettyPrintInfo(t *testing.T) { }) } } + +func TestFormatInfo(t *testing.T) { + for _, tc := range []struct { + doc string + template string + expectedError string + expectedOut string + }{ + { + doc: "basic", + template: "{{.ID}}", + expectedOut: sampleID + "\n", + }, + { + doc: "syntax", + template: "{{}", + expectedError: `Status: Template parsing error: template: :1: unexpected "}" in command, Code: 64`, + }, + } { + t.Run(tc.doc, func(t *testing.T) { + cli := test.NewFakeCli(&fakeClient{}) + err := formatInfo(cli, sampleInfoNoSwarm, tc.template) + if tc.expectedOut != "" { + assert.NilError(t, err) + assert.Equal(t, cli.OutBuffer().String(), tc.expectedOut) + } else if tc.expectedError != "" { + assert.Error(t, err, tc.expectedError) + } else { + t.Fatal("test expected to neither pass nor fail") + } + }) + } +} From 7913fb6a5eedea1d0b5e04efc648e5a57a529fc1 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Thu, 24 Jan 2019 12:29:06 +0000 Subject: [PATCH 2/5] Check json output in existing `docker info` unit tests. This is in addition to the more specific `formatInfo` unit tests added previously. Signed-off-by: Ian Campbell --- cli/command/system/info_test.go | 30 ++++++++++++------- .../docker-info-daemon-warnings.json.golden | 1 + .../docker-info-legacy-warnings.json.golden | 1 + .../testdata/docker-info-no-swarm.json.golden | 1 + .../docker-info-with-swarm.json.golden | 1 + 5 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 cli/command/system/testdata/docker-info-daemon-warnings.json.golden create mode 100644 cli/command/system/testdata/docker-info-legacy-warnings.json.golden create mode 100644 cli/command/system/testdata/docker-info-no-swarm.json.golden create mode 100644 cli/command/system/testdata/docker-info-with-swarm.json.golden diff --git a/cli/command/system/info_test.go b/cli/command/system/info_test.go index fa1a957f8b73..5b7c74826e42 100644 --- a/cli/command/system/info_test.go +++ b/cli/command/system/info_test.go @@ -227,41 +227,51 @@ func TestPrettyPrintInfo(t *testing.T) { for _, tc := range []struct { doc string dockerInfo types.Info - expectedGolden string + prettyGolden string warningsGolden string + jsonGolden string }{ { - doc: "info without swarm", - dockerInfo: sampleInfoNoSwarm, - expectedGolden: "docker-info-no-swarm", + doc: "info without swarm", + dockerInfo: sampleInfoNoSwarm, + prettyGolden: "docker-info-no-swarm", + jsonGolden: "docker-info-no-swarm", }, { - doc: "info with swarm", - dockerInfo: infoWithSwarm, - expectedGolden: "docker-info-with-swarm", + doc: "info with swarm", + dockerInfo: infoWithSwarm, + prettyGolden: "docker-info-with-swarm", + jsonGolden: "docker-info-with-swarm", }, { doc: "info with legacy warnings", dockerInfo: infoWithWarningsLinux, - expectedGolden: "docker-info-no-swarm", + prettyGolden: "docker-info-no-swarm", warningsGolden: "docker-info-warnings", + jsonGolden: "docker-info-legacy-warnings", }, { doc: "info with daemon warnings", dockerInfo: sampleInfoDaemonWarnings, - expectedGolden: "docker-info-no-swarm", + prettyGolden: "docker-info-no-swarm", warningsGolden: "docker-info-warnings", + jsonGolden: "docker-info-daemon-warnings", }, } { t.Run(tc.doc, func(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) assert.NilError(t, prettyPrintInfo(cli, tc.dockerInfo)) - golden.Assert(t, cli.OutBuffer().String(), tc.expectedGolden+".golden") + golden.Assert(t, cli.OutBuffer().String(), tc.prettyGolden+".golden") if tc.warningsGolden != "" { golden.Assert(t, cli.ErrBuffer().String(), tc.warningsGolden+".golden") } else { assert.Check(t, is.Equal("", cli.ErrBuffer().String())) } + + cli = test.NewFakeCli(&fakeClient{}) + assert.NilError(t, formatInfo(cli, tc.dockerInfo, "{{json .}}")) + golden.Assert(t, cli.OutBuffer().String(), tc.jsonGolden+".json.golden") + assert.Check(t, is.Equal("", cli.ErrBuffer().String())) }) } } diff --git a/cli/command/system/testdata/docker-info-daemon-warnings.json.golden b/cli/command/system/testdata/docker-info-daemon-warnings.json.golden new file mode 100644 index 000000000000..909eba9641b7 --- /dev/null +++ b/cli/command/system/testdata/docker-info-daemon-warnings.json.golden @@ -0,0 +1 @@ +{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":["WARNING: No memory limit support","WARNING: No swap limit support","WARNING: No kernel memory limit support","WARNING: No oom kill disable support","WARNING: No cpu cfs quota support","WARNING: No cpu cfs period support","WARNING: No cpu shares support","WARNING: No cpuset support","WARNING: IPv4 forwarding is disabled","WARNING: bridge-nf-call-iptables is disabled","WARNING: bridge-nf-call-ip6tables is disabled"]} diff --git a/cli/command/system/testdata/docker-info-legacy-warnings.json.golden b/cli/command/system/testdata/docker-info-legacy-warnings.json.golden new file mode 100644 index 000000000000..d71608c09d7b --- /dev/null +++ b/cli/command/system/testdata/docker-info-legacy-warnings.json.golden @@ -0,0 +1 @@ +{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":false,"SwapLimit":false,"KernelMemory":false,"KernelMemoryTCP":false,"CpuCfsPeriod":false,"CpuCfsQuota":false,"CPUShares":false,"CPUSet":false,"IPv4Forwarding":false,"BridgeNfIptables":false,"BridgeNfIp6tables":false,"Debug":true,"NFd":33,"OomKillDisable":false,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":null} diff --git a/cli/command/system/testdata/docker-info-no-swarm.json.golden b/cli/command/system/testdata/docker-info-no-swarm.json.golden new file mode 100644 index 000000000000..f4dea32f1cdb --- /dev/null +++ b/cli/command/system/testdata/docker-info-no-swarm.json.golden @@ -0,0 +1 @@ +{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":null} diff --git a/cli/command/system/testdata/docker-info-with-swarm.json.golden b/cli/command/system/testdata/docker-info-with-swarm.json.golden new file mode 100644 index 000000000000..65ced13906e8 --- /dev/null +++ b/cli/command/system/testdata/docker-info-with-swarm.json.golden @@ -0,0 +1 @@ +{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"qo2dfdig9mmxqkawulggepdih","NodeAddr":"165.227.107.89","LocalNodeState":"active","ControlAvailable":true,"Error":"","RemoteManagers":[{"NodeID":"qo2dfdig9mmxqkawulggepdih","Addr":"165.227.107.89:2377"}],"Nodes":1,"Managers":1,"Cluster":{"ID":"9vs5ygs0gguyyec4iqf2314c0","Version":{"Index":11},"CreatedAt":"2017-08-24T17:34:19.278062352Z","UpdatedAt":"2017-08-24T17:34:42.398815481Z","Spec":{"Name":"default","Labels":null,"Orchestration":{"TaskHistoryRetentionLimit":5},"Raft":{"SnapshotInterval":10000,"KeepOldSnapshots":0,"LogEntriesForSlowFollowers":500,"ElectionTick":3,"HeartbeatTick":1},"Dispatcher":{"HeartbeatPeriod":5000000000},"CAConfig":{"NodeCertExpiry":7776000000000000},"TaskDefaults":{},"EncryptionConfig":{"AutoLockManagers":true}},"TLSInfo":{"TrustRoot":"\n-----BEGIN CERTIFICATE-----\nMIIBajCCARCgAwIBAgIUaFCW5xsq8eyiJ+Pmcv3MCflMLnMwCgYIKoZIzj0EAwIw\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwODI0MTcyOTAwWhcNMzcwODE5MTcy\nOTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\nA0IABDy7NebyUJyUjWJDBUdnZoV6GBxEGKO4TZPNDwnxDxJcUdLVaB7WGa4/DLrW\nUfsVgh1JGik2VTiLuTMA1tLlNPOjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\nAf8EBTADAQH/MB0GA1UdDgQWBBQl16XFtaaXiUAwEuJptJlDjfKskDAKBggqhkjO\nPQQDAgNIADBFAiEAo9fTQNM5DP9bHVcTJYfl2Cay1bFu1E+lnpmN+EYJfeACIGKH\n1pCUkZ+D0IB6CiEZGWSHyLuXPM1rlP+I5KuS7sB8\n-----END CERTIFICATE-----\n","CertIssuerSubject":"MBMxETAPBgNVBAMTCHN3YXJtLWNh","CertIssuerPublicKey":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPLs15vJQnJSNYkMFR2dmhXoYHEQYo7hNk80PCfEPElxR0tVoHtYZrj8MutZR+xWCHUkaKTZVOIu5MwDW0uU08w=="},"RootRotationInProgress":false,"DefaultAddrPool":null,"SubnetSize":0,"DataPathPort":0}},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":null} From 62ed1c0c5bd90fb32f3e9d2185cc505c696c948a Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 23 Jan 2019 13:34:43 +0000 Subject: [PATCH 3/5] Separate client and daemon info in `docker system info` Right now the only client side info we have is whether debug is enabled, but we expect more in the future. We also preemptively prepare for the possibility of multiple errors when gathering both daemon and client info. Signed-off-by: Ian Campbell --- cli/command/system/info.go | 88 ++++++++++++++++--- cli/command/system/info_test.go | 54 +++++++++--- .../docker-info-daemon-warnings.json.golden | 2 +- .../system/testdata/docker-info-errors.golden | 7 ++ .../testdata/docker-info-errors.json.golden | 1 + .../docker-info-legacy-warnings.json.golden | 2 +- .../testdata/docker-info-no-swarm.golden | 9 +- .../testdata/docker-info-no-swarm.json.golden | 2 +- .../testdata/docker-info-with-swarm.golden | 9 +- .../docker-info-with-swarm.json.golden | 2 +- docs/reference/commandline/info.md | 24 +++-- man/src/system/info.md | 18 +++- 12 files changed, 177 insertions(+), 41 deletions(-) create mode 100644 cli/command/system/testdata/docker-info-errors.golden create mode 100644 cli/command/system/testdata/docker-info-errors.json.golden diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 2d6ac31ccc0b..4c65cfeaefd5 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -21,6 +21,23 @@ type infoOptions struct { format string } +type clientInfo struct { + Debug bool + Warnings []string +} + +type info struct { + // This field should/could be ServerInfo but is anonymous to + // preserve backwards compatibility in the JSON rendering + // which has ServerInfo immediately within the top-level + // object. + *types.Info `json:",omitempty"` + ServerErrors []string `json:",omitempty"` + + ClientInfo *clientInfo `json:",omitempty"` + ClientErrors []string `json:",omitempty"` +} + // NewInfoCommand creates a new cobra.Command for `docker info` func NewInfoCommand(dockerCli command.Cli) *cobra.Command { var opts infoOptions @@ -42,19 +59,67 @@ func NewInfoCommand(dockerCli command.Cli) *cobra.Command { } func runInfo(dockerCli command.Cli, opts *infoOptions) error { + var info info + ctx := context.Background() - info, err := dockerCli.Client().Info(ctx) - if err != nil { - return err + if dinfo, err := dockerCli.Client().Info(ctx); err == nil { + info.Info = &dinfo + } else { + info.ServerErrors = append(info.ServerErrors, err.Error()) } + + info.ClientInfo = &clientInfo{ + Debug: debug.IsEnabled(), + } + if opts.format == "" { return prettyPrintInfo(dockerCli, info) } return formatInfo(dockerCli, info, opts.format) } +func prettyPrintInfo(dockerCli command.Cli, info info) error { + fmt.Fprintln(dockerCli.Out(), "Client") + fmt.Fprintln(dockerCli.Out(), "------") + if info.ClientInfo != nil { + if err := prettyPrintClientInfo(dockerCli, *info.ClientInfo); err != nil { + info.ClientErrors = append(info.ClientErrors, err.Error()) + } + } + for _, err := range info.ClientErrors { + fmt.Fprintln(dockerCli.Out(), "ERROR:", err) + } + + fmt.Fprintln(dockerCli.Out()) + fmt.Fprintln(dockerCli.Out(), "Server") + fmt.Fprintln(dockerCli.Out(), "------") + if info.Info != nil { + if err := prettyPrintServerInfo(dockerCli, *info.Info); err != nil { + info.ServerErrors = append(info.ServerErrors, err.Error()) + } + } + for _, err := range info.ServerErrors { + fmt.Fprintln(dockerCli.Out(), "ERROR:", err) + } + + if len(info.ServerErrors) > 0 || len(info.ClientErrors) > 0 { + return fmt.Errorf("errors pretty printing info") + } + return nil +} + +func prettyPrintClientInfo(dockerCli command.Cli, info clientInfo) error { + fmt.Fprintln(dockerCli.Out(), "Debug Mode:", info.Debug) + + if len(info.Warnings) > 0 { + fmt.Fprintln(dockerCli.Err(), strings.Join(info.Warnings, "\n")) + } + + return nil +} + // nolint: gocyclo -func prettyPrintInfo(dockerCli command.Cli, info types.Info) error { +func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) error { fmt.Fprintln(dockerCli.Out(), "Containers:", info.Containers) fmt.Fprintln(dockerCli.Out(), " Running:", info.ContainersRunning) fmt.Fprintln(dockerCli.Out(), " Paused:", info.ContainersPaused) @@ -149,8 +214,7 @@ func prettyPrintInfo(dockerCli command.Cli, info types.Info) error { fprintlnNonEmpty(dockerCli.Out(), "Name:", info.Name) fprintlnNonEmpty(dockerCli.Out(), "ID:", info.ID) fmt.Fprintln(dockerCli.Out(), "Docker Root Dir:", info.DockerRootDir) - fmt.Fprintln(dockerCli.Out(), "Debug Mode (client):", debug.IsEnabled()) - fmt.Fprintln(dockerCli.Out(), "Debug Mode (server):", info.Debug) + fmt.Fprintln(dockerCli.Out(), "Debug Mode:", info.Debug) if info.Debug { fmt.Fprintln(dockerCli.Out(), " File Descriptors:", info.NFd) @@ -209,7 +273,7 @@ func prettyPrintInfo(dockerCli command.Cli, info types.Info) error { } fmt.Fprint(dockerCli.Out(), "\n") - printWarnings(dockerCli, info) + printServerWarnings(dockerCli, info) return nil } @@ -283,22 +347,22 @@ func printSwarmInfo(dockerCli command.Cli, info types.Info) { } } -func printWarnings(dockerCli command.Cli, info types.Info) { +func printServerWarnings(dockerCli command.Cli, info types.Info) { if len(info.Warnings) > 0 { fmt.Fprintln(dockerCli.Err(), strings.Join(info.Warnings, "\n")) return } // daemon didn't return warnings. Fallback to old behavior printStorageDriverWarnings(dockerCli, info) - printWarningsLegacy(dockerCli, info) + printServerWarningsLegacy(dockerCli, info) } -// printWarningsLegacy generates warnings based on information returned by the daemon. +// printServerWarningsLegacy generates warnings based on information returned by the daemon. // DEPRECATED: warnings are now generated by the daemon, and returned in // info.Warnings. This function is used to provide backward compatibility with // daemons that do not provide these warnings. No new warnings should be added // here. -func printWarningsLegacy(dockerCli command.Cli, info types.Info) { +func printServerWarningsLegacy(dockerCli command.Cli, info types.Info) { if info.OSType == "windows" { return } @@ -382,7 +446,7 @@ func getBackingFs(info types.Info) string { return "" } -func formatInfo(dockerCli command.Cli, info types.Info, format string) error { +func formatInfo(dockerCli command.Cli, info info, format string) error { tmpl, err := templates.Parse(format) if err != nil { return cli.StatusError{StatusCode: 64, diff --git a/cli/command/system/info_test.go b/cli/command/system/info_test.go index 5b7c74826e42..5b44935c2fec 100644 --- a/cli/command/system/info_test.go +++ b/cli/command/system/info_test.go @@ -226,41 +226,69 @@ func TestPrettyPrintInfo(t *testing.T) { for _, tc := range []struct { doc string - dockerInfo types.Info + dockerInfo info prettyGolden string warningsGolden string jsonGolden string + expectedError string }{ { - doc: "info without swarm", - dockerInfo: sampleInfoNoSwarm, + doc: "info without swarm", + dockerInfo: info{ + Info: &sampleInfoNoSwarm, + ClientInfo: &clientInfo{Debug: true}, + }, prettyGolden: "docker-info-no-swarm", jsonGolden: "docker-info-no-swarm", }, { - doc: "info with swarm", - dockerInfo: infoWithSwarm, + doc: "info with swarm", + dockerInfo: info{ + Info: &infoWithSwarm, + ClientInfo: &clientInfo{Debug: false}, + }, prettyGolden: "docker-info-with-swarm", jsonGolden: "docker-info-with-swarm", }, { - doc: "info with legacy warnings", - dockerInfo: infoWithWarningsLinux, + doc: "info with legacy warnings", + dockerInfo: info{ + Info: &infoWithWarningsLinux, + ClientInfo: &clientInfo{Debug: true}, + }, prettyGolden: "docker-info-no-swarm", warningsGolden: "docker-info-warnings", jsonGolden: "docker-info-legacy-warnings", }, { - doc: "info with daemon warnings", - dockerInfo: sampleInfoDaemonWarnings, + doc: "info with daemon warnings", + dockerInfo: info{ + Info: &sampleInfoDaemonWarnings, + ClientInfo: &clientInfo{Debug: true}, + }, prettyGolden: "docker-info-no-swarm", warningsGolden: "docker-info-warnings", jsonGolden: "docker-info-daemon-warnings", }, + { + doc: "errors for both", + dockerInfo: info{ + ServerErrors: []string{"a server error occurred"}, + ClientErrors: []string{"a client error occurred"}, + }, + prettyGolden: "docker-info-errors", + jsonGolden: "docker-info-errors", + expectedError: "errors pretty printing info", + }, } { t.Run(tc.doc, func(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) - assert.NilError(t, prettyPrintInfo(cli, tc.dockerInfo)) + err := prettyPrintInfo(cli, tc.dockerInfo) + if tc.expectedError == "" { + assert.NilError(t, err) + } else { + assert.Error(t, err, tc.expectedError) + } golden.Assert(t, cli.OutBuffer().String(), tc.prettyGolden+".golden") if tc.warningsGolden != "" { golden.Assert(t, cli.ErrBuffer().String(), tc.warningsGolden+".golden") @@ -296,7 +324,11 @@ func TestFormatInfo(t *testing.T) { } { t.Run(tc.doc, func(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) - err := formatInfo(cli, sampleInfoNoSwarm, tc.template) + info := info{ + Info: &sampleInfoNoSwarm, + ClientInfo: &clientInfo{Debug: true}, + } + err := formatInfo(cli, info, tc.template) if tc.expectedOut != "" { assert.NilError(t, err) assert.Equal(t, cli.OutBuffer().String(), tc.expectedOut) diff --git a/cli/command/system/testdata/docker-info-daemon-warnings.json.golden b/cli/command/system/testdata/docker-info-daemon-warnings.json.golden index 909eba9641b7..504939799d6e 100644 --- a/cli/command/system/testdata/docker-info-daemon-warnings.json.golden +++ b/cli/command/system/testdata/docker-info-daemon-warnings.json.golden @@ -1 +1 @@ -{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":["WARNING: No memory limit support","WARNING: No swap limit support","WARNING: No kernel memory limit support","WARNING: No oom kill disable support","WARNING: No cpu cfs quota support","WARNING: No cpu cfs period support","WARNING: No cpu shares support","WARNING: No cpuset support","WARNING: IPv4 forwarding is disabled","WARNING: bridge-nf-call-iptables is disabled","WARNING: bridge-nf-call-ip6tables is disabled"]} +{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":["WARNING: No memory limit support","WARNING: No swap limit support","WARNING: No kernel memory limit support","WARNING: No oom kill disable support","WARNING: No cpu cfs quota support","WARNING: No cpu cfs period support","WARNING: No cpu shares support","WARNING: No cpuset support","WARNING: IPv4 forwarding is disabled","WARNING: bridge-nf-call-iptables is disabled","WARNING: bridge-nf-call-ip6tables is disabled"],"ClientInfo":{"Debug":true,"Warnings":null}} diff --git a/cli/command/system/testdata/docker-info-errors.golden b/cli/command/system/testdata/docker-info-errors.golden new file mode 100644 index 000000000000..cac76a12af81 --- /dev/null +++ b/cli/command/system/testdata/docker-info-errors.golden @@ -0,0 +1,7 @@ +Client +------ +ERROR: a client error occurred + +Server +------ +ERROR: a server error occurred diff --git a/cli/command/system/testdata/docker-info-errors.json.golden b/cli/command/system/testdata/docker-info-errors.json.golden new file mode 100644 index 000000000000..3dcddd789816 --- /dev/null +++ b/cli/command/system/testdata/docker-info-errors.json.golden @@ -0,0 +1 @@ +{"ServerErrors":["a server error occurred"],"ClientErrors":["a client error occurred"]} diff --git a/cli/command/system/testdata/docker-info-legacy-warnings.json.golden b/cli/command/system/testdata/docker-info-legacy-warnings.json.golden index d71608c09d7b..489f700eb3e6 100644 --- a/cli/command/system/testdata/docker-info-legacy-warnings.json.golden +++ b/cli/command/system/testdata/docker-info-legacy-warnings.json.golden @@ -1 +1 @@ -{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":false,"SwapLimit":false,"KernelMemory":false,"KernelMemoryTCP":false,"CpuCfsPeriod":false,"CpuCfsQuota":false,"CPUShares":false,"CPUSet":false,"IPv4Forwarding":false,"BridgeNfIptables":false,"BridgeNfIp6tables":false,"Debug":true,"NFd":33,"OomKillDisable":false,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":null} +{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":false,"SwapLimit":false,"KernelMemory":false,"KernelMemoryTCP":false,"CpuCfsPeriod":false,"CpuCfsQuota":false,"CPUShares":false,"CPUSet":false,"IPv4Forwarding":false,"BridgeNfIptables":false,"BridgeNfIp6tables":false,"Debug":true,"NFd":33,"OomKillDisable":false,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":null,"ClientInfo":{"Debug":true,"Warnings":null}} diff --git a/cli/command/system/testdata/docker-info-no-swarm.golden b/cli/command/system/testdata/docker-info-no-swarm.golden index 7a3e9667356f..6c71576c1b44 100644 --- a/cli/command/system/testdata/docker-info-no-swarm.golden +++ b/cli/command/system/testdata/docker-info-no-swarm.golden @@ -1,3 +1,9 @@ +Client +------ +Debug Mode: true + +Server +------ Containers: 0 Running: 0 Paused: 0 @@ -35,8 +41,7 @@ Total Memory: 1.953GiB Name: system-sample ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX Docker Root Dir: /var/lib/docker -Debug Mode (client): false -Debug Mode (server): true +Debug Mode: true File Descriptors: 33 Goroutines: 135 System Time: 2017-08-24T17:44:34.077811894Z diff --git a/cli/command/system/testdata/docker-info-no-swarm.json.golden b/cli/command/system/testdata/docker-info-no-swarm.json.golden index f4dea32f1cdb..b99808753108 100644 --- a/cli/command/system/testdata/docker-info-no-swarm.json.golden +++ b/cli/command/system/testdata/docker-info-no-swarm.json.golden @@ -1 +1 @@ -{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":null} +{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":null,"ClientInfo":{"Debug":true,"Warnings":null}} diff --git a/cli/command/system/testdata/docker-info-with-swarm.golden b/cli/command/system/testdata/docker-info-with-swarm.golden index 17bb70fa7f58..cd9b08f38f66 100644 --- a/cli/command/system/testdata/docker-info-with-swarm.golden +++ b/cli/command/system/testdata/docker-info-with-swarm.golden @@ -1,3 +1,9 @@ +Client +------ +Debug Mode: false + +Server +------ Containers: 0 Running: 0 Paused: 0 @@ -57,8 +63,7 @@ Total Memory: 1.953GiB Name: system-sample ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX Docker Root Dir: /var/lib/docker -Debug Mode (client): false -Debug Mode (server): true +Debug Mode: true File Descriptors: 33 Goroutines: 135 System Time: 2017-08-24T17:44:34.077811894Z diff --git a/cli/command/system/testdata/docker-info-with-swarm.json.golden b/cli/command/system/testdata/docker-info-with-swarm.json.golden index 65ced13906e8..58ff6ea2b2fc 100644 --- a/cli/command/system/testdata/docker-info-with-swarm.json.golden +++ b/cli/command/system/testdata/docker-info-with-swarm.json.golden @@ -1 +1 @@ -{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"qo2dfdig9mmxqkawulggepdih","NodeAddr":"165.227.107.89","LocalNodeState":"active","ControlAvailable":true,"Error":"","RemoteManagers":[{"NodeID":"qo2dfdig9mmxqkawulggepdih","Addr":"165.227.107.89:2377"}],"Nodes":1,"Managers":1,"Cluster":{"ID":"9vs5ygs0gguyyec4iqf2314c0","Version":{"Index":11},"CreatedAt":"2017-08-24T17:34:19.278062352Z","UpdatedAt":"2017-08-24T17:34:42.398815481Z","Spec":{"Name":"default","Labels":null,"Orchestration":{"TaskHistoryRetentionLimit":5},"Raft":{"SnapshotInterval":10000,"KeepOldSnapshots":0,"LogEntriesForSlowFollowers":500,"ElectionTick":3,"HeartbeatTick":1},"Dispatcher":{"HeartbeatPeriod":5000000000},"CAConfig":{"NodeCertExpiry":7776000000000000},"TaskDefaults":{},"EncryptionConfig":{"AutoLockManagers":true}},"TLSInfo":{"TrustRoot":"\n-----BEGIN CERTIFICATE-----\nMIIBajCCARCgAwIBAgIUaFCW5xsq8eyiJ+Pmcv3MCflMLnMwCgYIKoZIzj0EAwIw\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwODI0MTcyOTAwWhcNMzcwODE5MTcy\nOTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\nA0IABDy7NebyUJyUjWJDBUdnZoV6GBxEGKO4TZPNDwnxDxJcUdLVaB7WGa4/DLrW\nUfsVgh1JGik2VTiLuTMA1tLlNPOjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\nAf8EBTADAQH/MB0GA1UdDgQWBBQl16XFtaaXiUAwEuJptJlDjfKskDAKBggqhkjO\nPQQDAgNIADBFAiEAo9fTQNM5DP9bHVcTJYfl2Cay1bFu1E+lnpmN+EYJfeACIGKH\n1pCUkZ+D0IB6CiEZGWSHyLuXPM1rlP+I5KuS7sB8\n-----END CERTIFICATE-----\n","CertIssuerSubject":"MBMxETAPBgNVBAMTCHN3YXJtLWNh","CertIssuerPublicKey":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPLs15vJQnJSNYkMFR2dmhXoYHEQYo7hNk80PCfEPElxR0tVoHtYZrj8MutZR+xWCHUkaKTZVOIu5MwDW0uU08w=="},"RootRotationInProgress":false,"DefaultAddrPool":null,"SubnetSize":0,"DataPathPort":0}},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":null} +{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"qo2dfdig9mmxqkawulggepdih","NodeAddr":"165.227.107.89","LocalNodeState":"active","ControlAvailable":true,"Error":"","RemoteManagers":[{"NodeID":"qo2dfdig9mmxqkawulggepdih","Addr":"165.227.107.89:2377"}],"Nodes":1,"Managers":1,"Cluster":{"ID":"9vs5ygs0gguyyec4iqf2314c0","Version":{"Index":11},"CreatedAt":"2017-08-24T17:34:19.278062352Z","UpdatedAt":"2017-08-24T17:34:42.398815481Z","Spec":{"Name":"default","Labels":null,"Orchestration":{"TaskHistoryRetentionLimit":5},"Raft":{"SnapshotInterval":10000,"KeepOldSnapshots":0,"LogEntriesForSlowFollowers":500,"ElectionTick":3,"HeartbeatTick":1},"Dispatcher":{"HeartbeatPeriod":5000000000},"CAConfig":{"NodeCertExpiry":7776000000000000},"TaskDefaults":{},"EncryptionConfig":{"AutoLockManagers":true}},"TLSInfo":{"TrustRoot":"\n-----BEGIN CERTIFICATE-----\nMIIBajCCARCgAwIBAgIUaFCW5xsq8eyiJ+Pmcv3MCflMLnMwCgYIKoZIzj0EAwIw\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwODI0MTcyOTAwWhcNMzcwODE5MTcy\nOTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\nA0IABDy7NebyUJyUjWJDBUdnZoV6GBxEGKO4TZPNDwnxDxJcUdLVaB7WGa4/DLrW\nUfsVgh1JGik2VTiLuTMA1tLlNPOjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\nAf8EBTADAQH/MB0GA1UdDgQWBBQl16XFtaaXiUAwEuJptJlDjfKskDAKBggqhkjO\nPQQDAgNIADBFAiEAo9fTQNM5DP9bHVcTJYfl2Cay1bFu1E+lnpmN+EYJfeACIGKH\n1pCUkZ+D0IB6CiEZGWSHyLuXPM1rlP+I5KuS7sB8\n-----END CERTIFICATE-----\n","CertIssuerSubject":"MBMxETAPBgNVBAMTCHN3YXJtLWNh","CertIssuerPublicKey":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPLs15vJQnJSNYkMFR2dmhXoYHEQYo7hNk80PCfEPElxR0tVoHtYZrj8MutZR+xWCHUkaKTZVOIu5MwDW0uU08w=="},"RootRotationInProgress":false,"DefaultAddrPool":null,"SubnetSize":0,"DataPathPort":0}},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"Warnings":null,"ClientInfo":{"Debug":false,"Warnings":null}} diff --git a/docs/reference/commandline/info.md b/docs/reference/commandline/info.md index 87f47076f144..fc64141ed35a 100644 --- a/docs/reference/commandline/info.md +++ b/docs/reference/commandline/info.md @@ -55,7 +55,12 @@ information about the `devicemapper` storage driver is shown: ```bash $ docker info +Client +------ +Debug Mode: false +Server +------ Containers: 14 Running: 3 Paused: 1 @@ -96,8 +101,7 @@ Total Memory: 991.7 MiB Name: ip-172-30-0-91.ec2.internal ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S Docker Root Dir: /var/lib/docker -Debug mode (client): false -Debug mode (server): false +Debug Mode: false Username: gordontheturtle Registry: https://index.docker.io/v1/ Insecure registries: @@ -112,7 +116,12 @@ storage driver and a node that is part of a 2-node swarm: ```bash $ docker -D info +Client +------ +Debug Mode: true +Server +------ Containers: 14 Running: 3 Paused: 1 @@ -168,8 +177,7 @@ Total Memory: 1.937 GiB Name: ubuntu ID: H52R:7ZR6:EIIA:76JG:ORIY:BVKF:GSFU:HNPG:B5MK:APSC:SZ3Q:N326 Docker Root Dir: /var/lib/docker -Debug Mode (client): true -Debug Mode (server): true +Debug Mode: true File Descriptors: 30 Goroutines: 123 System Time: 2016-11-12T17:24:37.955404361-08:00 @@ -209,7 +217,12 @@ Here is a sample output for a daemon running on Windows Server 2016: ```none E:\docker>docker info +Client +------ +Debug Mode: false +Server +------ Containers: 1 Running: 0 Paused: 0 @@ -233,8 +246,7 @@ Total Memory: 3.999 GiB Name: WIN-V0V70C0LU5P ID: NYMS:B5VK:UMSL:FVDZ:EWB5:FKVK:LPFL:FJMQ:H6FT:BZJ6:L2TD:XH62 Docker Root Dir: C:\control -Debug Mode (client): false -Debug Mode (server): false +Debug Mode: false Registry: https://index.docker.io/v1/ Insecure Registries: 127.0.0.0/8 diff --git a/man/src/system/info.md b/man/src/system/info.md index 9a87e985edab..774f72f465a3 100644 --- a/man/src/system/info.md +++ b/man/src/system/info.md @@ -24,6 +24,12 @@ Here is a sample output for a daemon running on Ubuntu, using the overlay2 storage driver: $ docker -D info + Client + ------ + Debug Mode: true + + Server + ------ Containers: 14 Running: 3 Paused: 1 @@ -78,8 +84,7 @@ storage driver: Name: ubuntu ID: H52R:7ZR6:EIIA:76JG:ORIY:BVKF:GSFU:HNPG:B5MK:APSC:SZ3Q:N326 Docker Root Dir: /var/lib/docker - Debug Mode (client): true - Debug Mode (server): true + Debug Mode: true File Descriptors: 30 Goroutines: 123 System Time: 2016-11-12T17:24:37.955404361-08:00 @@ -109,6 +114,12 @@ using the devicemapper storage driver. As can be seen in the output, additional information about the devicemapper storage driver is shown: $ docker info + Client + ------ + Debug Mode: false + + Server + ------ Containers: 14 Running: 3 Paused: 1 @@ -149,8 +160,7 @@ information about the devicemapper storage driver is shown: Name: ip-172-30-0-91.ec2.internal ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S Docker Root Dir: /var/lib/docker - Debug mode (client): false - Debug mode (server): false + Debug Mode: false Username: gordontheturtle Registry: https://index.docker.io/v1/ Insecure registries: From c9e60ae17a118555196ab827f366629c4884bbb6 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Thu, 24 Jan 2019 14:22:55 +0000 Subject: [PATCH 4/5] Allow `prettyPrintInfo` to return multiple errors This allows it to print what it can, rather than aborting half way when a bad security context is hit. Signed-off-by: Ian Campbell --- cli/command/system/info.go | 34 ++++++------ cli/command/system/info_test.go | 14 +++++ .../system/testdata/docker-info-badsec.golden | 54 +++++++++++++++++++ .../testdata/docker-info-badsec.json.golden | 1 + 4 files changed, 87 insertions(+), 16 deletions(-) create mode 100644 cli/command/system/testdata/docker-info-badsec.golden create mode 100644 cli/command/system/testdata/docker-info-badsec.json.golden diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 4c65cfeaefd5..2ec94db0fa79 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -94,7 +94,7 @@ func prettyPrintInfo(dockerCli command.Cli, info info) error { fmt.Fprintln(dockerCli.Out(), "Server") fmt.Fprintln(dockerCli.Out(), "------") if info.Info != nil { - if err := prettyPrintServerInfo(dockerCli, *info.Info); err != nil { + for _, err := range prettyPrintServerInfo(dockerCli, *info.Info) { info.ServerErrors = append(info.ServerErrors, err.Error()) } } @@ -119,7 +119,9 @@ func prettyPrintClientInfo(dockerCli command.Cli, info clientInfo) error { } // nolint: gocyclo -func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) error { +func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) []error { + var errs []error + fmt.Fprintln(dockerCli.Out(), "Containers:", info.Containers) fmt.Fprintln(dockerCli.Out(), " Running:", info.ContainersRunning) fmt.Fprintln(dockerCli.Out(), " Paused:", info.ContainersPaused) @@ -180,20 +182,20 @@ func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) error { fmt.Fprint(dockerCli.Out(), "\n") } if len(info.SecurityOptions) != 0 { - kvs, err := types.DecodeSecurityOptions(info.SecurityOptions) - if err != nil { - return err - } - fmt.Fprintln(dockerCli.Out(), "Security Options:") - for _, so := range kvs { - fmt.Fprintln(dockerCli.Out(), " "+so.Name) - for _, o := range so.Options { - switch o.Key { - case "profile": - if o.Value != "default" { - fmt.Fprintln(dockerCli.Err(), " WARNING: You're not using the default seccomp profile") + if kvs, err := types.DecodeSecurityOptions(info.SecurityOptions); err != nil { + errs = append(errs, err) + } else { + fmt.Fprintln(dockerCli.Out(), "Security Options:") + for _, so := range kvs { + fmt.Fprintln(dockerCli.Out(), " "+so.Name) + for _, o := range so.Options { + switch o.Key { + case "profile": + if o.Value != "default" { + fmt.Fprintln(dockerCli.Err(), " WARNING: You're not using the default seccomp profile") + } + fmt.Fprintln(dockerCli.Out(), " Profile:", o.Value) } - fmt.Fprintln(dockerCli.Out(), " Profile:", o.Value) } } } @@ -274,7 +276,7 @@ func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) error { fmt.Fprint(dockerCli.Out(), "\n") printServerWarnings(dockerCli, info) - return nil + return errs } // nolint: gocyclo diff --git a/cli/command/system/info_test.go b/cli/command/system/info_test.go index 5b44935c2fec..d3bcd7e02af6 100644 --- a/cli/command/system/info_test.go +++ b/cli/command/system/info_test.go @@ -224,6 +224,9 @@ func TestPrettyPrintInfo(t *testing.T) { "WARNING: bridge-nf-call-ip6tables is disabled", } + sampleInfoBadSecurity := sampleInfoNoSwarm + sampleInfoBadSecurity.SecurityOptions = []string{"foo="} + for _, tc := range []struct { doc string dockerInfo info @@ -280,6 +283,17 @@ func TestPrettyPrintInfo(t *testing.T) { jsonGolden: "docker-info-errors", expectedError: "errors pretty printing info", }, + { + doc: "bad security info", + dockerInfo: info{ + Info: &sampleInfoBadSecurity, + ServerErrors: []string{"an error happened"}, + ClientInfo: &clientInfo{Debug: false}, + }, + prettyGolden: "docker-info-badsec", + jsonGolden: "docker-info-badsec", + expectedError: "errors pretty printing info", + }, } { t.Run(tc.doc, func(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) diff --git a/cli/command/system/testdata/docker-info-badsec.golden b/cli/command/system/testdata/docker-info-badsec.golden new file mode 100644 index 000000000000..337991ca7411 --- /dev/null +++ b/cli/command/system/testdata/docker-info-badsec.golden @@ -0,0 +1,54 @@ +Client +------ +Debug Mode: false + +Server +------ +Containers: 0 + Running: 0 + Paused: 0 + Stopped: 0 +Images: 0 +Server Version: 17.06.1-ce +Storage Driver: aufs + Root Dir: /var/lib/docker/aufs + Backing Filesystem: extfs + Dirs: 0 + Dirperm1 Supported: true +Logging Driver: json-file +Cgroup Driver: cgroupfs +Plugins: + Volume: local + Network: bridge host macvlan null overlay + Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog +Swarm: inactive +Runtimes: runc +Default Runtime: runc +Init Binary: docker-init +containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170 +runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2 +init version: 949e6fa +Kernel Version: 4.4.0-87-generic +Operating System: Ubuntu 16.04.3 LTS +OSType: linux +Architecture: x86_64 +CPUs: 2 +Total Memory: 1.953GiB +Name: system-sample +ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX +Docker Root Dir: /var/lib/docker +Debug Mode: true + File Descriptors: 33 + Goroutines: 135 + System Time: 2017-08-24T17:44:34.077811894Z + EventsListeners: 0 +Registry: https://index.docker.io/v1/ +Labels: + provider=digitalocean +Experimental: false +Insecure Registries: + 127.0.0.0/8 +Live Restore Enabled: false + +ERROR: an error happened +ERROR: invalid empty security option diff --git a/cli/command/system/testdata/docker-info-badsec.json.golden b/cli/command/system/testdata/docker-info-badsec.json.golden new file mode 100644 index 000000000000..4b15ac022239 --- /dev/null +++ b/cli/command/system/testdata/docker-info-badsec.json.golden @@ -0,0 +1 @@ +{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","0"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"KernelMemoryTCP":false,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":null,"Secure":true,"Official":true}},"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["foo="],"Warnings":null,"ServerErrors":["an error happened"],"ClientInfo":{"Debug":false,"Warnings":null}} From bcb06b5f58aee62521737a60703c44d41405710c Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Fri, 25 Jan 2019 13:10:59 +0000 Subject: [PATCH 5/5] Rework `docker info` output to be more like `docker version` That is, reindent the two sections by one space. While the code was done by hand the `.golden` files had the extra space inserted with emacs' `string-insert-rectangle` macro to (try to) avoid possible manual errors. The docs were edited the same way. Signed-off-by: Ian Campbell --- cli/command/system/info.go | 178 +++++----- .../system/testdata/docker-info-badsec.golden | 98 +++-- .../system/testdata/docker-info-errors.golden | 6 +- .../testdata/docker-info-no-swarm.golden | 106 +++--- .../testdata/docker-info-with-swarm.golden | 150 ++++---- docs/reference/commandline/info.md | 336 +++++++++--------- man/src/system/info.md | 264 +++++++------- 7 files changed, 559 insertions(+), 579 deletions(-) diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 2ec94db0fa79..29380ea1a3e5 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -79,8 +79,7 @@ func runInfo(dockerCli command.Cli, opts *infoOptions) error { } func prettyPrintInfo(dockerCli command.Cli, info info) error { - fmt.Fprintln(dockerCli.Out(), "Client") - fmt.Fprintln(dockerCli.Out(), "------") + fmt.Fprintln(dockerCli.Out(), "Client:") if info.ClientInfo != nil { if err := prettyPrintClientInfo(dockerCli, *info.ClientInfo); err != nil { info.ClientErrors = append(info.ClientErrors, err.Error()) @@ -91,8 +90,7 @@ func prettyPrintInfo(dockerCli command.Cli, info info) error { } fmt.Fprintln(dockerCli.Out()) - fmt.Fprintln(dockerCli.Out(), "Server") - fmt.Fprintln(dockerCli.Out(), "------") + fmt.Fprintln(dockerCli.Out(), "Server:") if info.Info != nil { for _, err := range prettyPrintServerInfo(dockerCli, *info.Info) { info.ServerErrors = append(info.ServerErrors, err.Error()) @@ -109,7 +107,7 @@ func prettyPrintInfo(dockerCli command.Cli, info info) error { } func prettyPrintClientInfo(dockerCli command.Cli, info clientInfo) error { - fmt.Fprintln(dockerCli.Out(), "Debug Mode:", info.Debug) + fmt.Fprintln(dockerCli.Out(), " Debug Mode:", info.Debug) if len(info.Warnings) > 0 { fmt.Fprintln(dockerCli.Err(), strings.Join(info.Warnings, "\n")) @@ -122,50 +120,50 @@ func prettyPrintClientInfo(dockerCli command.Cli, info clientInfo) error { func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) []error { var errs []error - fmt.Fprintln(dockerCli.Out(), "Containers:", info.Containers) - fmt.Fprintln(dockerCli.Out(), " Running:", info.ContainersRunning) - fmt.Fprintln(dockerCli.Out(), " Paused:", info.ContainersPaused) - fmt.Fprintln(dockerCli.Out(), " Stopped:", info.ContainersStopped) - fmt.Fprintln(dockerCli.Out(), "Images:", info.Images) - fprintlnNonEmpty(dockerCli.Out(), "Server Version:", info.ServerVersion) - fprintlnNonEmpty(dockerCli.Out(), "Storage Driver:", info.Driver) + fmt.Fprintln(dockerCli.Out(), " Containers:", info.Containers) + fmt.Fprintln(dockerCli.Out(), " Running:", info.ContainersRunning) + fmt.Fprintln(dockerCli.Out(), " Paused:", info.ContainersPaused) + fmt.Fprintln(dockerCli.Out(), " Stopped:", info.ContainersStopped) + fmt.Fprintln(dockerCli.Out(), " Images:", info.Images) + fprintlnNonEmpty(dockerCli.Out(), " Server Version:", info.ServerVersion) + fprintlnNonEmpty(dockerCli.Out(), " Storage Driver:", info.Driver) if info.DriverStatus != nil { for _, pair := range info.DriverStatus { - fmt.Fprintf(dockerCli.Out(), " %s: %s\n", pair[0], pair[1]) + fmt.Fprintf(dockerCli.Out(), " %s: %s\n", pair[0], pair[1]) } } if info.SystemStatus != nil { for _, pair := range info.SystemStatus { - fmt.Fprintf(dockerCli.Out(), "%s: %s\n", pair[0], pair[1]) + fmt.Fprintf(dockerCli.Out(), " %s: %s\n", pair[0], pair[1]) } } - fprintlnNonEmpty(dockerCli.Out(), "Logging Driver:", info.LoggingDriver) - fprintlnNonEmpty(dockerCli.Out(), "Cgroup Driver:", info.CgroupDriver) + fprintlnNonEmpty(dockerCli.Out(), " Logging Driver:", info.LoggingDriver) + fprintlnNonEmpty(dockerCli.Out(), " Cgroup Driver:", info.CgroupDriver) - fmt.Fprintln(dockerCli.Out(), "Plugins:") - fmt.Fprintln(dockerCli.Out(), " Volume:", strings.Join(info.Plugins.Volume, " ")) - fmt.Fprintln(dockerCli.Out(), " Network:", strings.Join(info.Plugins.Network, " ")) + fmt.Fprintln(dockerCli.Out(), " Plugins:") + fmt.Fprintln(dockerCli.Out(), " Volume:", strings.Join(info.Plugins.Volume, " ")) + fmt.Fprintln(dockerCli.Out(), " Network:", strings.Join(info.Plugins.Network, " ")) if len(info.Plugins.Authorization) != 0 { - fmt.Fprintln(dockerCli.Out(), " Authorization:", strings.Join(info.Plugins.Authorization, " ")) + fmt.Fprintln(dockerCli.Out(), " Authorization:", strings.Join(info.Plugins.Authorization, " ")) } - fmt.Fprintln(dockerCli.Out(), " Log:", strings.Join(info.Plugins.Log, " ")) + fmt.Fprintln(dockerCli.Out(), " Log:", strings.Join(info.Plugins.Log, " ")) - fmt.Fprintln(dockerCli.Out(), "Swarm:", info.Swarm.LocalNodeState) + fmt.Fprintln(dockerCli.Out(), " Swarm:", info.Swarm.LocalNodeState) printSwarmInfo(dockerCli, info) if len(info.Runtimes) > 0 { - fmt.Fprint(dockerCli.Out(), "Runtimes:") + fmt.Fprint(dockerCli.Out(), " Runtimes:") for name := range info.Runtimes { fmt.Fprintf(dockerCli.Out(), " %s", name) } fmt.Fprint(dockerCli.Out(), "\n") - fmt.Fprintln(dockerCli.Out(), "Default Runtime:", info.DefaultRuntime) + fmt.Fprintln(dockerCli.Out(), " Default Runtime:", info.DefaultRuntime) } if info.OSType == "linux" { - fmt.Fprintln(dockerCli.Out(), "Init Binary:", info.InitBinary) + fmt.Fprintln(dockerCli.Out(), " Init Binary:", info.InitBinary) for _, ci := range []struct { Name string @@ -175,7 +173,7 @@ func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) []error { {"runc", info.RuncCommit}, {"init", info.InitCommit}, } { - fmt.Fprintf(dockerCli.Out(), "%s version: %s", ci.Name, ci.Commit.ID) + fmt.Fprintf(dockerCli.Out(), " %s version: %s", ci.Name, ci.Commit.ID) if ci.Commit.ID != ci.Commit.Expected { fmt.Fprintf(dockerCli.Out(), " (expected: %s)", ci.Commit.Expected) } @@ -185,16 +183,16 @@ func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) []error { if kvs, err := types.DecodeSecurityOptions(info.SecurityOptions); err != nil { errs = append(errs, err) } else { - fmt.Fprintln(dockerCli.Out(), "Security Options:") + fmt.Fprintln(dockerCli.Out(), " Security Options:") for _, so := range kvs { - fmt.Fprintln(dockerCli.Out(), " "+so.Name) + fmt.Fprintln(dockerCli.Out(), " "+so.Name) for _, o := range so.Options { switch o.Key { case "profile": if o.Value != "default" { fmt.Fprintln(dockerCli.Err(), " WARNING: You're not using the default seccomp profile") } - fmt.Fprintln(dockerCli.Out(), " Profile:", o.Value) + fmt.Fprintln(dockerCli.Out(), " Profile:", o.Value) } } } @@ -204,74 +202,74 @@ func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) []error { // Isolation only has meaning on a Windows daemon. if info.OSType == "windows" { - fmt.Fprintln(dockerCli.Out(), "Default Isolation:", info.Isolation) + fmt.Fprintln(dockerCli.Out(), " Default Isolation:", info.Isolation) } - fprintlnNonEmpty(dockerCli.Out(), "Kernel Version:", info.KernelVersion) - fprintlnNonEmpty(dockerCli.Out(), "Operating System:", info.OperatingSystem) - fprintlnNonEmpty(dockerCli.Out(), "OSType:", info.OSType) - fprintlnNonEmpty(dockerCli.Out(), "Architecture:", info.Architecture) - fmt.Fprintln(dockerCli.Out(), "CPUs:", info.NCPU) - fmt.Fprintln(dockerCli.Out(), "Total Memory:", units.BytesSize(float64(info.MemTotal))) - fprintlnNonEmpty(dockerCli.Out(), "Name:", info.Name) - fprintlnNonEmpty(dockerCli.Out(), "ID:", info.ID) - fmt.Fprintln(dockerCli.Out(), "Docker Root Dir:", info.DockerRootDir) - fmt.Fprintln(dockerCli.Out(), "Debug Mode:", info.Debug) + fprintlnNonEmpty(dockerCli.Out(), " Kernel Version:", info.KernelVersion) + fprintlnNonEmpty(dockerCli.Out(), " Operating System:", info.OperatingSystem) + fprintlnNonEmpty(dockerCli.Out(), " OSType:", info.OSType) + fprintlnNonEmpty(dockerCli.Out(), " Architecture:", info.Architecture) + fmt.Fprintln(dockerCli.Out(), " CPUs:", info.NCPU) + fmt.Fprintln(dockerCli.Out(), " Total Memory:", units.BytesSize(float64(info.MemTotal))) + fprintlnNonEmpty(dockerCli.Out(), " Name:", info.Name) + fprintlnNonEmpty(dockerCli.Out(), " ID:", info.ID) + fmt.Fprintln(dockerCli.Out(), " Docker Root Dir:", info.DockerRootDir) + fmt.Fprintln(dockerCli.Out(), " Debug Mode:", info.Debug) if info.Debug { - fmt.Fprintln(dockerCli.Out(), " File Descriptors:", info.NFd) - fmt.Fprintln(dockerCli.Out(), " Goroutines:", info.NGoroutines) - fmt.Fprintln(dockerCli.Out(), " System Time:", info.SystemTime) - fmt.Fprintln(dockerCli.Out(), " EventsListeners:", info.NEventsListener) + fmt.Fprintln(dockerCli.Out(), " File Descriptors:", info.NFd) + fmt.Fprintln(dockerCli.Out(), " Goroutines:", info.NGoroutines) + fmt.Fprintln(dockerCli.Out(), " System Time:", info.SystemTime) + fmt.Fprintln(dockerCli.Out(), " EventsListeners:", info.NEventsListener) } - fprintlnNonEmpty(dockerCli.Out(), "HTTP Proxy:", info.HTTPProxy) - fprintlnNonEmpty(dockerCli.Out(), "HTTPS Proxy:", info.HTTPSProxy) - fprintlnNonEmpty(dockerCli.Out(), "No Proxy:", info.NoProxy) + fprintlnNonEmpty(dockerCli.Out(), " HTTP Proxy:", info.HTTPProxy) + fprintlnNonEmpty(dockerCli.Out(), " HTTPS Proxy:", info.HTTPSProxy) + fprintlnNonEmpty(dockerCli.Out(), " No Proxy:", info.NoProxy) if info.IndexServerAddress != "" { u := dockerCli.ConfigFile().AuthConfigs[info.IndexServerAddress].Username if len(u) > 0 { - fmt.Fprintln(dockerCli.Out(), "Username:", u) + fmt.Fprintln(dockerCli.Out(), " Username:", u) } - fmt.Fprintln(dockerCli.Out(), "Registry:", info.IndexServerAddress) + fmt.Fprintln(dockerCli.Out(), " Registry:", info.IndexServerAddress) } if info.Labels != nil { - fmt.Fprintln(dockerCli.Out(), "Labels:") + fmt.Fprintln(dockerCli.Out(), " Labels:") for _, lbl := range info.Labels { - fmt.Fprintln(dockerCli.Out(), " "+lbl) + fmt.Fprintln(dockerCli.Out(), " "+lbl) } } - fmt.Fprintln(dockerCli.Out(), "Experimental:", info.ExperimentalBuild) - fprintlnNonEmpty(dockerCli.Out(), "Cluster Store:", info.ClusterStore) - fprintlnNonEmpty(dockerCli.Out(), "Cluster Advertise:", info.ClusterAdvertise) + fmt.Fprintln(dockerCli.Out(), " Experimental:", info.ExperimentalBuild) + fprintlnNonEmpty(dockerCli.Out(), " Cluster Store:", info.ClusterStore) + fprintlnNonEmpty(dockerCli.Out(), " Cluster Advertise:", info.ClusterAdvertise) if info.RegistryConfig != nil && (len(info.RegistryConfig.InsecureRegistryCIDRs) > 0 || len(info.RegistryConfig.IndexConfigs) > 0) { - fmt.Fprintln(dockerCli.Out(), "Insecure Registries:") + fmt.Fprintln(dockerCli.Out(), " Insecure Registries:") for _, registry := range info.RegistryConfig.IndexConfigs { if !registry.Secure { - fmt.Fprintln(dockerCli.Out(), " "+registry.Name) + fmt.Fprintln(dockerCli.Out(), " "+registry.Name) } } for _, registry := range info.RegistryConfig.InsecureRegistryCIDRs { mask, _ := registry.Mask.Size() - fmt.Fprintf(dockerCli.Out(), " %s/%d\n", registry.IP.String(), mask) + fmt.Fprintf(dockerCli.Out(), " %s/%d\n", registry.IP.String(), mask) } } if info.RegistryConfig != nil && len(info.RegistryConfig.Mirrors) > 0 { - fmt.Fprintln(dockerCli.Out(), "Registry Mirrors:") + fmt.Fprintln(dockerCli.Out(), " Registry Mirrors:") for _, mirror := range info.RegistryConfig.Mirrors { - fmt.Fprintln(dockerCli.Out(), " "+mirror) + fmt.Fprintln(dockerCli.Out(), " "+mirror) } } - fmt.Fprintln(dockerCli.Out(), "Live Restore Enabled:", info.LiveRestoreEnabled) + fmt.Fprintln(dockerCli.Out(), " Live Restore Enabled:", info.LiveRestoreEnabled) if info.ProductLicense != "" { - fmt.Fprintln(dockerCli.Out(), "Product License:", info.ProductLicense) + fmt.Fprintln(dockerCli.Out(), " Product License:", info.ProductLicense) } fmt.Fprint(dockerCli.Out(), "\n") @@ -284,67 +282,67 @@ func printSwarmInfo(dockerCli command.Cli, info types.Info) { if info.Swarm.LocalNodeState == swarm.LocalNodeStateInactive || info.Swarm.LocalNodeState == swarm.LocalNodeStateLocked { return } - fmt.Fprintln(dockerCli.Out(), " NodeID:", info.Swarm.NodeID) + fmt.Fprintln(dockerCli.Out(), " NodeID:", info.Swarm.NodeID) if info.Swarm.Error != "" { - fmt.Fprintln(dockerCli.Out(), " Error:", info.Swarm.Error) + fmt.Fprintln(dockerCli.Out(), " Error:", info.Swarm.Error) } - fmt.Fprintln(dockerCli.Out(), " Is Manager:", info.Swarm.ControlAvailable) + fmt.Fprintln(dockerCli.Out(), " Is Manager:", info.Swarm.ControlAvailable) if info.Swarm.Cluster != nil && info.Swarm.ControlAvailable && info.Swarm.Error == "" && info.Swarm.LocalNodeState != swarm.LocalNodeStateError { - fmt.Fprintln(dockerCli.Out(), " ClusterID:", info.Swarm.Cluster.ID) - fmt.Fprintln(dockerCli.Out(), " Managers:", info.Swarm.Managers) - fmt.Fprintln(dockerCli.Out(), " Nodes:", info.Swarm.Nodes) + fmt.Fprintln(dockerCli.Out(), " ClusterID:", info.Swarm.Cluster.ID) + fmt.Fprintln(dockerCli.Out(), " Managers:", info.Swarm.Managers) + fmt.Fprintln(dockerCli.Out(), " Nodes:", info.Swarm.Nodes) var strAddrPool strings.Builder if info.Swarm.Cluster.DefaultAddrPool != nil { for _, p := range info.Swarm.Cluster.DefaultAddrPool { strAddrPool.WriteString(p + " ") } - fmt.Fprintln(dockerCli.Out(), " Default Address Pool:", strAddrPool.String()) - fmt.Fprintln(dockerCli.Out(), " SubnetSize:", info.Swarm.Cluster.SubnetSize) + fmt.Fprintln(dockerCli.Out(), " Default Address Pool:", strAddrPool.String()) + fmt.Fprintln(dockerCli.Out(), " SubnetSize:", info.Swarm.Cluster.SubnetSize) } if info.Swarm.Cluster.DataPathPort > 0 { - fmt.Fprintln(dockerCli.Out(), " Data Path Port:", info.Swarm.Cluster.DataPathPort) + fmt.Fprintln(dockerCli.Out(), " Data Path Port:", info.Swarm.Cluster.DataPathPort) } - fmt.Fprintln(dockerCli.Out(), " Orchestration:") + fmt.Fprintln(dockerCli.Out(), " Orchestration:") taskHistoryRetentionLimit := int64(0) if info.Swarm.Cluster.Spec.Orchestration.TaskHistoryRetentionLimit != nil { taskHistoryRetentionLimit = *info.Swarm.Cluster.Spec.Orchestration.TaskHistoryRetentionLimit } - fmt.Fprintln(dockerCli.Out(), " Task History Retention Limit:", taskHistoryRetentionLimit) - fmt.Fprintln(dockerCli.Out(), " Raft:") - fmt.Fprintln(dockerCli.Out(), " Snapshot Interval:", info.Swarm.Cluster.Spec.Raft.SnapshotInterval) + fmt.Fprintln(dockerCli.Out(), " Task History Retention Limit:", taskHistoryRetentionLimit) + fmt.Fprintln(dockerCli.Out(), " Raft:") + fmt.Fprintln(dockerCli.Out(), " Snapshot Interval:", info.Swarm.Cluster.Spec.Raft.SnapshotInterval) if info.Swarm.Cluster.Spec.Raft.KeepOldSnapshots != nil { - fmt.Fprintf(dockerCli.Out(), " Number of Old Snapshots to Retain: %d\n", *info.Swarm.Cluster.Spec.Raft.KeepOldSnapshots) + fmt.Fprintf(dockerCli.Out(), " Number of Old Snapshots to Retain: %d\n", *info.Swarm.Cluster.Spec.Raft.KeepOldSnapshots) } - fmt.Fprintln(dockerCli.Out(), " Heartbeat Tick:", info.Swarm.Cluster.Spec.Raft.HeartbeatTick) - fmt.Fprintln(dockerCli.Out(), " Election Tick:", info.Swarm.Cluster.Spec.Raft.ElectionTick) - fmt.Fprintln(dockerCli.Out(), " Dispatcher:") - fmt.Fprintln(dockerCli.Out(), " Heartbeat Period:", units.HumanDuration(info.Swarm.Cluster.Spec.Dispatcher.HeartbeatPeriod)) - fmt.Fprintln(dockerCli.Out(), " CA Configuration:") - fmt.Fprintln(dockerCli.Out(), " Expiry Duration:", units.HumanDuration(info.Swarm.Cluster.Spec.CAConfig.NodeCertExpiry)) - fmt.Fprintln(dockerCli.Out(), " Force Rotate:", info.Swarm.Cluster.Spec.CAConfig.ForceRotate) + fmt.Fprintln(dockerCli.Out(), " Heartbeat Tick:", info.Swarm.Cluster.Spec.Raft.HeartbeatTick) + fmt.Fprintln(dockerCli.Out(), " Election Tick:", info.Swarm.Cluster.Spec.Raft.ElectionTick) + fmt.Fprintln(dockerCli.Out(), " Dispatcher:") + fmt.Fprintln(dockerCli.Out(), " Heartbeat Period:", units.HumanDuration(info.Swarm.Cluster.Spec.Dispatcher.HeartbeatPeriod)) + fmt.Fprintln(dockerCli.Out(), " CA Configuration:") + fmt.Fprintln(dockerCli.Out(), " Expiry Duration:", units.HumanDuration(info.Swarm.Cluster.Spec.CAConfig.NodeCertExpiry)) + fmt.Fprintln(dockerCli.Out(), " Force Rotate:", info.Swarm.Cluster.Spec.CAConfig.ForceRotate) if caCert := strings.TrimSpace(info.Swarm.Cluster.Spec.CAConfig.SigningCACert); caCert != "" { - fmt.Fprintf(dockerCli.Out(), " Signing CA Certificate: \n%s\n\n", caCert) + fmt.Fprintf(dockerCli.Out(), " Signing CA Certificate: \n%s\n\n", caCert) } if len(info.Swarm.Cluster.Spec.CAConfig.ExternalCAs) > 0 { - fmt.Fprintln(dockerCli.Out(), " External CAs:") + fmt.Fprintln(dockerCli.Out(), " External CAs:") for _, entry := range info.Swarm.Cluster.Spec.CAConfig.ExternalCAs { - fmt.Fprintf(dockerCli.Out(), " %s: %s\n", entry.Protocol, entry.URL) + fmt.Fprintf(dockerCli.Out(), " %s: %s\n", entry.Protocol, entry.URL) } } - fmt.Fprintln(dockerCli.Out(), " Autolock Managers:", info.Swarm.Cluster.Spec.EncryptionConfig.AutoLockManagers) - fmt.Fprintln(dockerCli.Out(), " Root Rotation In Progress:", info.Swarm.Cluster.RootRotationInProgress) + fmt.Fprintln(dockerCli.Out(), " Autolock Managers:", info.Swarm.Cluster.Spec.EncryptionConfig.AutoLockManagers) + fmt.Fprintln(dockerCli.Out(), " Root Rotation In Progress:", info.Swarm.Cluster.RootRotationInProgress) } - fmt.Fprintln(dockerCli.Out(), " Node Address:", info.Swarm.NodeAddr) + fmt.Fprintln(dockerCli.Out(), " Node Address:", info.Swarm.NodeAddr) if len(info.Swarm.RemoteManagers) > 0 { managers := []string{} for _, entry := range info.Swarm.RemoteManagers { managers = append(managers, entry.Addr) } sort.Strings(managers) - fmt.Fprintln(dockerCli.Out(), " Manager Addresses:") + fmt.Fprintln(dockerCli.Out(), " Manager Addresses:") for _, entry := range managers { - fmt.Fprintf(dockerCli.Out(), " %s\n", entry) + fmt.Fprintf(dockerCli.Out(), " %s\n", entry) } } } diff --git a/cli/command/system/testdata/docker-info-badsec.golden b/cli/command/system/testdata/docker-info-badsec.golden index 337991ca7411..7c074e8d55f7 100644 --- a/cli/command/system/testdata/docker-info-badsec.golden +++ b/cli/command/system/testdata/docker-info-badsec.golden @@ -1,54 +1,52 @@ -Client ------- -Debug Mode: false +Client: + Debug Mode: false -Server ------- -Containers: 0 - Running: 0 - Paused: 0 - Stopped: 0 -Images: 0 -Server Version: 17.06.1-ce -Storage Driver: aufs - Root Dir: /var/lib/docker/aufs - Backing Filesystem: extfs - Dirs: 0 - Dirperm1 Supported: true -Logging Driver: json-file -Cgroup Driver: cgroupfs -Plugins: - Volume: local - Network: bridge host macvlan null overlay - Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog -Swarm: inactive -Runtimes: runc -Default Runtime: runc -Init Binary: docker-init -containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170 -runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2 -init version: 949e6fa -Kernel Version: 4.4.0-87-generic -Operating System: Ubuntu 16.04.3 LTS -OSType: linux -Architecture: x86_64 -CPUs: 2 -Total Memory: 1.953GiB -Name: system-sample -ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX -Docker Root Dir: /var/lib/docker -Debug Mode: true - File Descriptors: 33 - Goroutines: 135 - System Time: 2017-08-24T17:44:34.077811894Z - EventsListeners: 0 -Registry: https://index.docker.io/v1/ -Labels: - provider=digitalocean -Experimental: false -Insecure Registries: - 127.0.0.0/8 -Live Restore Enabled: false +Server: + Containers: 0 + Running: 0 + Paused: 0 + Stopped: 0 + Images: 0 + Server Version: 17.06.1-ce + Storage Driver: aufs + Root Dir: /var/lib/docker/aufs + Backing Filesystem: extfs + Dirs: 0 + Dirperm1 Supported: true + Logging Driver: json-file + Cgroup Driver: cgroupfs + Plugins: + Volume: local + Network: bridge host macvlan null overlay + Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog + Swarm: inactive + Runtimes: runc + Default Runtime: runc + Init Binary: docker-init + containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170 + runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2 + init version: 949e6fa + Kernel Version: 4.4.0-87-generic + Operating System: Ubuntu 16.04.3 LTS + OSType: linux + Architecture: x86_64 + CPUs: 2 + Total Memory: 1.953GiB + Name: system-sample + ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX + Docker Root Dir: /var/lib/docker + Debug Mode: true + File Descriptors: 33 + Goroutines: 135 + System Time: 2017-08-24T17:44:34.077811894Z + EventsListeners: 0 + Registry: https://index.docker.io/v1/ + Labels: + provider=digitalocean + Experimental: false + Insecure Registries: + 127.0.0.0/8 + Live Restore Enabled: false ERROR: an error happened ERROR: invalid empty security option diff --git a/cli/command/system/testdata/docker-info-errors.golden b/cli/command/system/testdata/docker-info-errors.golden index cac76a12af81..549611ee1342 100644 --- a/cli/command/system/testdata/docker-info-errors.golden +++ b/cli/command/system/testdata/docker-info-errors.golden @@ -1,7 +1,5 @@ -Client ------- +Client: ERROR: a client error occurred -Server ------- +Server: ERROR: a server error occurred diff --git a/cli/command/system/testdata/docker-info-no-swarm.golden b/cli/command/system/testdata/docker-info-no-swarm.golden index 6c71576c1b44..b1539de0db59 100644 --- a/cli/command/system/testdata/docker-info-no-swarm.golden +++ b/cli/command/system/testdata/docker-info-no-swarm.golden @@ -1,56 +1,54 @@ -Client ------- -Debug Mode: true +Client: + Debug Mode: true -Server ------- -Containers: 0 - Running: 0 - Paused: 0 - Stopped: 0 -Images: 0 -Server Version: 17.06.1-ce -Storage Driver: aufs - Root Dir: /var/lib/docker/aufs - Backing Filesystem: extfs - Dirs: 0 - Dirperm1 Supported: true -Logging Driver: json-file -Cgroup Driver: cgroupfs -Plugins: - Volume: local - Network: bridge host macvlan null overlay - Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog -Swarm: inactive -Runtimes: runc -Default Runtime: runc -Init Binary: docker-init -containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170 -runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2 -init version: 949e6fa -Security Options: - apparmor - seccomp - Profile: default -Kernel Version: 4.4.0-87-generic -Operating System: Ubuntu 16.04.3 LTS -OSType: linux -Architecture: x86_64 -CPUs: 2 -Total Memory: 1.953GiB -Name: system-sample -ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX -Docker Root Dir: /var/lib/docker -Debug Mode: true - File Descriptors: 33 - Goroutines: 135 - System Time: 2017-08-24T17:44:34.077811894Z - EventsListeners: 0 -Registry: https://index.docker.io/v1/ -Labels: - provider=digitalocean -Experimental: false -Insecure Registries: - 127.0.0.0/8 -Live Restore Enabled: false +Server: + Containers: 0 + Running: 0 + Paused: 0 + Stopped: 0 + Images: 0 + Server Version: 17.06.1-ce + Storage Driver: aufs + Root Dir: /var/lib/docker/aufs + Backing Filesystem: extfs + Dirs: 0 + Dirperm1 Supported: true + Logging Driver: json-file + Cgroup Driver: cgroupfs + Plugins: + Volume: local + Network: bridge host macvlan null overlay + Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog + Swarm: inactive + Runtimes: runc + Default Runtime: runc + Init Binary: docker-init + containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170 + runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2 + init version: 949e6fa + Security Options: + apparmor + seccomp + Profile: default + Kernel Version: 4.4.0-87-generic + Operating System: Ubuntu 16.04.3 LTS + OSType: linux + Architecture: x86_64 + CPUs: 2 + Total Memory: 1.953GiB + Name: system-sample + ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX + Docker Root Dir: /var/lib/docker + Debug Mode: true + File Descriptors: 33 + Goroutines: 135 + System Time: 2017-08-24T17:44:34.077811894Z + EventsListeners: 0 + Registry: https://index.docker.io/v1/ + Labels: + provider=digitalocean + Experimental: false + Insecure Registries: + 127.0.0.0/8 + Live Restore Enabled: false diff --git a/cli/command/system/testdata/docker-info-with-swarm.golden b/cli/command/system/testdata/docker-info-with-swarm.golden index cd9b08f38f66..e6c04f695c08 100644 --- a/cli/command/system/testdata/docker-info-with-swarm.golden +++ b/cli/command/system/testdata/docker-info-with-swarm.golden @@ -1,78 +1,76 @@ -Client ------- -Debug Mode: false +Client: + Debug Mode: false -Server ------- -Containers: 0 - Running: 0 - Paused: 0 - Stopped: 0 -Images: 0 -Server Version: 17.06.1-ce -Storage Driver: aufs - Root Dir: /var/lib/docker/aufs - Backing Filesystem: extfs - Dirs: 0 - Dirperm1 Supported: true -Logging Driver: json-file -Cgroup Driver: cgroupfs -Plugins: - Volume: local - Network: bridge host macvlan null overlay - Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog -Swarm: active - NodeID: qo2dfdig9mmxqkawulggepdih - Is Manager: true - ClusterID: 9vs5ygs0gguyyec4iqf2314c0 - Managers: 1 - Nodes: 1 - Orchestration: - Task History Retention Limit: 5 - Raft: - Snapshot Interval: 10000 - Number of Old Snapshots to Retain: 0 - Heartbeat Tick: 1 - Election Tick: 3 - Dispatcher: - Heartbeat Period: 5 seconds - CA Configuration: - Expiry Duration: 3 months - Force Rotate: 0 - Autolock Managers: true - Root Rotation In Progress: false - Node Address: 165.227.107.89 - Manager Addresses: - 165.227.107.89:2377 -Runtimes: runc -Default Runtime: runc -Init Binary: docker-init -containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170 -runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2 -init version: 949e6fa -Security Options: - apparmor - seccomp - Profile: default -Kernel Version: 4.4.0-87-generic -Operating System: Ubuntu 16.04.3 LTS -OSType: linux -Architecture: x86_64 -CPUs: 2 -Total Memory: 1.953GiB -Name: system-sample -ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX -Docker Root Dir: /var/lib/docker -Debug Mode: true - File Descriptors: 33 - Goroutines: 135 - System Time: 2017-08-24T17:44:34.077811894Z - EventsListeners: 0 -Registry: https://index.docker.io/v1/ -Labels: - provider=digitalocean -Experimental: false -Insecure Registries: - 127.0.0.0/8 -Live Restore Enabled: false +Server: + Containers: 0 + Running: 0 + Paused: 0 + Stopped: 0 + Images: 0 + Server Version: 17.06.1-ce + Storage Driver: aufs + Root Dir: /var/lib/docker/aufs + Backing Filesystem: extfs + Dirs: 0 + Dirperm1 Supported: true + Logging Driver: json-file + Cgroup Driver: cgroupfs + Plugins: + Volume: local + Network: bridge host macvlan null overlay + Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog + Swarm: active + NodeID: qo2dfdig9mmxqkawulggepdih + Is Manager: true + ClusterID: 9vs5ygs0gguyyec4iqf2314c0 + Managers: 1 + Nodes: 1 + Orchestration: + Task History Retention Limit: 5 + Raft: + Snapshot Interval: 10000 + Number of Old Snapshots to Retain: 0 + Heartbeat Tick: 1 + Election Tick: 3 + Dispatcher: + Heartbeat Period: 5 seconds + CA Configuration: + Expiry Duration: 3 months + Force Rotate: 0 + Autolock Managers: true + Root Rotation In Progress: false + Node Address: 165.227.107.89 + Manager Addresses: + 165.227.107.89:2377 + Runtimes: runc + Default Runtime: runc + Init Binary: docker-init + containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170 + runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2 + init version: 949e6fa + Security Options: + apparmor + seccomp + Profile: default + Kernel Version: 4.4.0-87-generic + Operating System: Ubuntu 16.04.3 LTS + OSType: linux + Architecture: x86_64 + CPUs: 2 + Total Memory: 1.953GiB + Name: system-sample + ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX + Docker Root Dir: /var/lib/docker + Debug Mode: true + File Descriptors: 33 + Goroutines: 135 + System Time: 2017-08-24T17:44:34.077811894Z + EventsListeners: 0 + Registry: https://index.docker.io/v1/ + Labels: + provider=digitalocean + Experimental: false + Insecure Registries: + 127.0.0.0/8 + Live Restore Enabled: false diff --git a/docs/reference/commandline/info.md b/docs/reference/commandline/info.md index fc64141ed35a..aee122008da9 100644 --- a/docs/reference/commandline/info.md +++ b/docs/reference/commandline/info.md @@ -55,60 +55,58 @@ information about the `devicemapper` storage driver is shown: ```bash $ docker info -Client ------- -Debug Mode: false - -Server ------- -Containers: 14 - Running: 3 - Paused: 1 - Stopped: 10 -Images: 52 -Server Version: 1.10.3 -Storage Driver: devicemapper - Pool Name: docker-202:2-25583803-pool - Pool Blocksize: 65.54 kB - Base Device Size: 10.74 GB - Backing Filesystem: xfs - Data file: /dev/loop0 - Metadata file: /dev/loop1 - Data Space Used: 1.68 GB - Data Space Total: 107.4 GB - Data Space Available: 7.548 GB - Metadata Space Used: 2.322 MB - Metadata Space Total: 2.147 GB - Metadata Space Available: 2.145 GB - Udev Sync Supported: true - Deferred Removal Enabled: false - Deferred Deletion Enabled: false - Deferred Deleted Device Count: 0 - Data loop file: /var/lib/docker/devicemapper/devicemapper/data - Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata - Library Version: 1.02.107-RHEL7 (2015-12-01) -Execution Driver: native-0.2 -Logging Driver: json-file -Plugins: - Volume: local - Network: null host bridge -Kernel Version: 3.10.0-327.el7.x86_64 -Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo) -OSType: linux -Architecture: x86_64 -CPUs: 1 -Total Memory: 991.7 MiB -Name: ip-172-30-0-91.ec2.internal -ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S -Docker Root Dir: /var/lib/docker -Debug Mode: false -Username: gordontheturtle -Registry: https://index.docker.io/v1/ -Insecure registries: - myinsecurehost:5000 - 127.0.0.0/8 +Client: + Debug Mode: false + +Server: + Containers: 14 + Running: 3 + Paused: 1 + Stopped: 10 + Images: 52 + Server Version: 1.10.3 + Storage Driver: devicemapper + Pool Name: docker-202:2-25583803-pool + Pool Blocksize: 65.54 kB + Base Device Size: 10.74 GB + Backing Filesystem: xfs + Data file: /dev/loop0 + Metadata file: /dev/loop1 + Data Space Used: 1.68 GB + Data Space Total: 107.4 GB + Data Space Available: 7.548 GB + Metadata Space Used: 2.322 MB + Metadata Space Total: 2.147 GB + Metadata Space Available: 2.145 GB + Udev Sync Supported: true + Deferred Removal Enabled: false + Deferred Deletion Enabled: false + Deferred Deleted Device Count: 0 + Data loop file: /var/lib/docker/devicemapper/devicemapper/data + Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata + Library Version: 1.02.107-RHEL7 (2015-12-01) + Execution Driver: native-0.2 + Logging Driver: json-file + Plugins: + Volume: local + Network: null host bridge + Kernel Version: 3.10.0-327.el7.x86_64 + Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo) + OSType: linux + Architecture: x86_64 + CPUs: 1 + Total Memory: 991.7 MiB + Name: ip-172-30-0-91.ec2.internal + ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S + Docker Root Dir: /var/lib/docker + Debug Mode: false + Username: gordontheturtle + Registry: https://index.docker.io/v1/ + Insecure registries: + myinsecurehost:5000 + 127.0.0.0/8 ``` - + ### Show debugging output Here is a sample output for a daemon running on Ubuntu, using the overlay2 @@ -116,87 +114,85 @@ storage driver and a node that is part of a 2-node swarm: ```bash $ docker -D info -Client ------- -Debug Mode: true - -Server ------- -Containers: 14 - Running: 3 - Paused: 1 - Stopped: 10 -Images: 52 -Server Version: 1.13.0 -Storage Driver: overlay2 - Backing Filesystem: extfs - Supports d_type: true - Native Overlay Diff: false -Logging Driver: json-file -Cgroup Driver: cgroupfs -Plugins: - Volume: local - Network: bridge host macvlan null overlay -Swarm: active - NodeID: rdjq45w1op418waxlairloqbm - Is Manager: true - ClusterID: te8kdyw33n36fqiz74bfjeixd - Managers: 1 - Nodes: 2 - Orchestration: - Task History Retention Limit: 5 - Raft: - Snapshot Interval: 10000 - Number of Old Snapshots to Retain: 0 - Heartbeat Tick: 1 - Election Tick: 3 - Dispatcher: - Heartbeat Period: 5 seconds - CA Configuration: - Expiry Duration: 3 months - Root Rotation In Progress: false - Node Address: 172.16.66.128 172.16.66.129 - Manager Addresses: - 172.16.66.128:2477 -Runtimes: runc -Default Runtime: runc -Init Binary: docker-init -containerd version: 8517738ba4b82aff5662c97ca4627e7e4d03b531 -runc version: ac031b5bf1cc92239461125f4c1ffb760522bbf2 -init version: N/A (expected: v0.13.0) -Security Options: - apparmor - seccomp - Profile: default -Kernel Version: 4.4.0-31-generic -Operating System: Ubuntu 16.04.1 LTS -OSType: linux -Architecture: x86_64 -CPUs: 2 -Total Memory: 1.937 GiB -Name: ubuntu -ID: H52R:7ZR6:EIIA:76JG:ORIY:BVKF:GSFU:HNPG:B5MK:APSC:SZ3Q:N326 -Docker Root Dir: /var/lib/docker -Debug Mode: true - File Descriptors: 30 - Goroutines: 123 - System Time: 2016-11-12T17:24:37.955404361-08:00 - EventsListeners: 0 -Http Proxy: http://test:test@proxy.example.com:8080 -Https Proxy: https://test:test@proxy.example.com:8080 -No Proxy: localhost,127.0.0.1,docker-registry.somecorporation.com -Registry: https://index.docker.io/v1/ -WARNING: No swap limit support -Labels: - storage=ssd - staging=true -Experimental: false -Insecure Registries: - 127.0.0.0/8 -Registry Mirrors: - http://192.168.1.2/ - http://registry-mirror.example.com:5000/ -Live Restore Enabled: false +Client: + Debug Mode: true + +Server: + Containers: 14 + Running: 3 + Paused: 1 + Stopped: 10 + Images: 52 + Server Version: 1.13.0 + Storage Driver: overlay2 + Backing Filesystem: extfs + Supports d_type: true + Native Overlay Diff: false + Logging Driver: json-file + Cgroup Driver: cgroupfs + Plugins: + Volume: local + Network: bridge host macvlan null overlay + Swarm: active + NodeID: rdjq45w1op418waxlairloqbm + Is Manager: true + ClusterID: te8kdyw33n36fqiz74bfjeixd + Managers: 1 + Nodes: 2 + Orchestration: + Task History Retention Limit: 5 + Raft: + Snapshot Interval: 10000 + Number of Old Snapshots to Retain: 0 + Heartbeat Tick: 1 + Election Tick: 3 + Dispatcher: + Heartbeat Period: 5 seconds + CA Configuration: + Expiry Duration: 3 months + Root Rotation In Progress: false + Node Address: 172.16.66.128 172.16.66.129 + Manager Addresses: + 172.16.66.128:2477 + Runtimes: runc + Default Runtime: runc + Init Binary: docker-init + containerd version: 8517738ba4b82aff5662c97ca4627e7e4d03b531 + runc version: ac031b5bf1cc92239461125f4c1ffb760522bbf2 + init version: N/A (expected: v0.13.0) + Security Options: + apparmor + seccomp + Profile: default + Kernel Version: 4.4.0-31-generic + Operating System: Ubuntu 16.04.1 LTS + OSType: linux + Architecture: x86_64 + CPUs: 2 + Total Memory: 1.937 GiB + Name: ubuntu + ID: H52R:7ZR6:EIIA:76JG:ORIY:BVKF:GSFU:HNPG:B5MK:APSC:SZ3Q:N326 + Docker Root Dir: /var/lib/docker + Debug Mode: true + File Descriptors: 30 + Goroutines: 123 + System Time: 2016-11-12T17:24:37.955404361-08:00 + EventsListeners: 0 + Http Proxy: http://test:test@proxy.example.com:8080 + Https Proxy: https://test:test@proxy.example.com:8080 + No Proxy: localhost,127.0.0.1,docker-registry.somecorporation.com + Registry: https://index.docker.io/v1/ + WARNING: No swap limit support + Labels: + storage=ssd + staging=true + Experimental: false + Insecure Registries: + 127.0.0.0/8 + Registry Mirrors: + http://192.168.1.2/ + http://registry-mirror.example.com:5000/ + Live Restore Enabled: false ``` The global `-D` option causes all `docker` commands to output debug information. @@ -217,41 +213,39 @@ Here is a sample output for a daemon running on Windows Server 2016: ```none E:\docker>docker info -Client ------- -Debug Mode: false - -Server ------- -Containers: 1 - Running: 0 - Paused: 0 - Stopped: 1 -Images: 17 -Server Version: 1.13.0 -Storage Driver: windowsfilter - Windows: -Logging Driver: json-file -Plugins: - Volume: local - Network: nat null overlay -Swarm: inactive -Default Isolation: process -Kernel Version: 10.0 14393 (14393.206.amd64fre.rs1_release.160912-1937) -Operating System: Windows Server 2016 Datacenter -OSType: windows -Architecture: x86_64 -CPUs: 8 -Total Memory: 3.999 GiB -Name: WIN-V0V70C0LU5P -ID: NYMS:B5VK:UMSL:FVDZ:EWB5:FKVK:LPFL:FJMQ:H6FT:BZJ6:L2TD:XH62 -Docker Root Dir: C:\control -Debug Mode: false -Registry: https://index.docker.io/v1/ -Insecure Registries: - 127.0.0.0/8 -Registry Mirrors: - http://192.168.1.2/ - http://registry-mirror.example.com:5000/ -Live Restore Enabled: false +Client: + Debug Mode: false + +Server: + Containers: 1 + Running: 0 + Paused: 0 + Stopped: 1 + Images: 17 + Server Version: 1.13.0 + Storage Driver: windowsfilter + Windows: + Logging Driver: json-file + Plugins: + Volume: local + Network: nat null overlay + Swarm: inactive + Default Isolation: process + Kernel Version: 10.0 14393 (14393.206.amd64fre.rs1_release.160912-1937) + Operating System: Windows Server 2016 Datacenter + OSType: windows + Architecture: x86_64 + CPUs: 8 + Total Memory: 3.999 GiB + Name: WIN-V0V70C0LU5P + ID: NYMS:B5VK:UMSL:FVDZ:EWB5:FKVK:LPFL:FJMQ:H6FT:BZJ6:L2TD:XH62 + Docker Root Dir: C:\control + Debug Mode: false + Registry: https://index.docker.io/v1/ + Insecure Registries: + 127.0.0.0/8 + Registry Mirrors: + http://192.168.1.2/ + http://registry-mirror.example.com:5000/ + Live Restore Enabled: false ``` diff --git a/man/src/system/info.md b/man/src/system/info.md index 774f72f465a3..14c04a31a538 100644 --- a/man/src/system/info.md +++ b/man/src/system/info.md @@ -24,87 +24,85 @@ Here is a sample output for a daemon running on Ubuntu, using the overlay2 storage driver: $ docker -D info - Client - ------ - Debug Mode: true - - Server - ------ - Containers: 14 - Running: 3 - Paused: 1 - Stopped: 10 - Images: 52 - Server Version: 1.13.0 - Storage Driver: overlay2 - Backing Filesystem: extfs - Supports d_type: true - Native Overlay Diff: false - Logging Driver: json-file - Cgroup Driver: cgroupfs - Plugins: - Volume: local - Network: bridge host macvlan null overlay - Swarm: active - NodeID: rdjq45w1op418waxlairloqbm - Is Manager: true - ClusterID: te8kdyw33n36fqiz74bfjeixd - Managers: 1 - Nodes: 2 - Orchestration: - Task History Retention Limit: 5 - Raft: - Snapshot Interval: 10000 - Number of Old Snapshots to Retain: 0 - Heartbeat Tick: 1 - Election Tick: 3 - Dispatcher: - Heartbeat Period: 5 seconds - CA Configuration: - Expiry Duration: 3 months - Node Address: 172.16.66.128 172.16.66.129 - Manager Addresses: - 172.16.66.128:2477 - Runtimes: runc - Default Runtime: runc - Init Binary: docker-init - containerd version: 8517738ba4b82aff5662c97ca4627e7e4d03b531 - runc version: ac031b5bf1cc92239461125f4c1ffb760522bbf2 - init version: N/A (expected: v0.13.0) - Security Options: - apparmor - seccomp - Profile: default - Kernel Version: 4.4.0-31-generic - Operating System: Ubuntu 16.04.1 LTS - OSType: linux - Architecture: x86_64 - CPUs: 2 - Total Memory: 1.937 GiB - Name: ubuntu - ID: H52R:7ZR6:EIIA:76JG:ORIY:BVKF:GSFU:HNPG:B5MK:APSC:SZ3Q:N326 - Docker Root Dir: /var/lib/docker - Debug Mode: true - File Descriptors: 30 - Goroutines: 123 - System Time: 2016-11-12T17:24:37.955404361-08:00 - EventsListeners: 0 - Http Proxy: http://test:test@proxy.example.com:8080 - Https Proxy: https://test:test@proxy.example.com:8080 - No Proxy: localhost,127.0.0.1,docker-registry.somecorporation.com - Registry: https://index.docker.io/v1/ - WARNING: No swap limit support - Labels: - storage=ssd - staging=true - Experimental: false - Insecure Registries: - 127.0.0.0/8 - Registry Mirrors: - http://192.168.1.2/ - http://registry-mirror.example.com:5000/ - Live Restore Enabled: false - + Client: + Debug Mode: true + + Server: + Containers: 14 + Running: 3 + Paused: 1 + Stopped: 10 + Images: 52 + Server Version: 1.13.0 + Storage Driver: overlay2 + Backing Filesystem: extfs + Supports d_type: true + Native Overlay Diff: false + Logging Driver: json-file + Cgroup Driver: cgroupfs + Plugins: + Volume: local + Network: bridge host macvlan null overlay + Swarm: active + NodeID: rdjq45w1op418waxlairloqbm + Is Manager: true + ClusterID: te8kdyw33n36fqiz74bfjeixd + Managers: 1 + Nodes: 2 + Orchestration: + Task History Retention Limit: 5 + Raft: + Snapshot Interval: 10000 + Number of Old Snapshots to Retain: 0 + Heartbeat Tick: 1 + Election Tick: 3 + Dispatcher: + Heartbeat Period: 5 seconds + CA Configuration: + Expiry Duration: 3 months + Node Address: 172.16.66.128 172.16.66.129 + Manager Addresses: + 172.16.66.128:2477 + Runtimes: runc + Default Runtime: runc + Init Binary: docker-init + containerd version: 8517738ba4b82aff5662c97ca4627e7e4d03b531 + runc version: ac031b5bf1cc92239461125f4c1ffb760522bbf2 + init version: N/A (expected: v0.13.0) + Security Options: + apparmor + seccomp + Profile: default + Kernel Version: 4.4.0-31-generic + Operating System: Ubuntu 16.04.1 LTS + OSType: linux + Architecture: x86_64 + CPUs: 2 + Total Memory: 1.937 GiB + Name: ubuntu + ID: H52R:7ZR6:EIIA:76JG:ORIY:BVKF:GSFU:HNPG:B5MK:APSC:SZ3Q:N326 + Docker Root Dir: /var/lib/docker + Debug Mode: true + File Descriptors: 30 + Goroutines: 123 + System Time: 2016-11-12T17:24:37.955404361-08:00 + EventsListeners: 0 + Http Proxy: http://test:test@proxy.example.com:8080 + Https Proxy: https://test:test@proxy.example.com:8080 + No Proxy: localhost,127.0.0.1,docker-registry.somecorporation.com + Registry: https://index.docker.io/v1/ + WARNING: No swap limit support + Labels: + storage=ssd + staging=true + Experimental: false + Insecure Registries: + 127.0.0.0/8 + Registry Mirrors: + http://192.168.1.2/ + http://registry-mirror.example.com:5000/ + Live Restore Enabled: false + The global `-D` option tells all `docker` commands to output debug information. @@ -114,59 +112,57 @@ using the devicemapper storage driver. As can be seen in the output, additional information about the devicemapper storage driver is shown: $ docker info - Client - ------ - Debug Mode: false - - Server - ------ - Containers: 14 - Running: 3 - Paused: 1 - Stopped: 10 - Untagged Images: 52 - Server Version: 1.10.3 - Storage Driver: devicemapper - Pool Name: docker-202:2-25583803-pool - Pool Blocksize: 65.54 kB - Base Device Size: 10.74 GB - Backing Filesystem: xfs - Data file: /dev/loop0 - Metadata file: /dev/loop1 - Data Space Used: 1.68 GB - Data Space Total: 107.4 GB - Data Space Available: 7.548 GB - Metadata Space Used: 2.322 MB - Metadata Space Total: 2.147 GB - Metadata Space Available: 2.145 GB - Udev Sync Supported: true - Deferred Removal Enabled: false - Deferred Deletion Enabled: false - Deferred Deleted Device Count: 0 - Data loop file: /var/lib/docker/devicemapper/devicemapper/data - Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata - Library Version: 1.02.107-RHEL7 (2015-12-01) - Execution Driver: native-0.2 - Logging Driver: json-file - Plugins: - Volume: local - Network: null host bridge - Kernel Version: 3.10.0-327.el7.x86_64 - Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo) - OSType: linux - Architecture: x86_64 - CPUs: 1 - Total Memory: 991.7 MiB - Name: ip-172-30-0-91.ec2.internal - ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S - Docker Root Dir: /var/lib/docker - Debug Mode: false - Username: gordontheturtle - Registry: https://index.docker.io/v1/ - Insecure registries: - myinsecurehost:5000 - 127.0.0.0/8 - + Client: + Debug Mode: false + + Server: + Containers: 14 + Running: 3 + Paused: 1 + Stopped: 10 + Untagged Images: 52 + Server Version: 1.10.3 + Storage Driver: devicemapper + Pool Name: docker-202:2-25583803-pool + Pool Blocksize: 65.54 kB + Base Device Size: 10.74 GB + Backing Filesystem: xfs + Data file: /dev/loop0 + Metadata file: /dev/loop1 + Data Space Used: 1.68 GB + Data Space Total: 107.4 GB + Data Space Available: 7.548 GB + Metadata Space Used: 2.322 MB + Metadata Space Total: 2.147 GB + Metadata Space Available: 2.145 GB + Udev Sync Supported: true + Deferred Removal Enabled: false + Deferred Deletion Enabled: false + Deferred Deleted Device Count: 0 + Data loop file: /var/lib/docker/devicemapper/devicemapper/data + Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata + Library Version: 1.02.107-RHEL7 (2015-12-01) + Execution Driver: native-0.2 + Logging Driver: json-file + Plugins: + Volume: local + Network: null host bridge + Kernel Version: 3.10.0-327.el7.x86_64 + Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo) + OSType: linux + Architecture: x86_64 + CPUs: 1 + Total Memory: 991.7 MiB + Name: ip-172-30-0-91.ec2.internal + ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S + Docker Root Dir: /var/lib/docker + Debug Mode: false + Username: gordontheturtle + Registry: https://index.docker.io/v1/ + Insecure registries: + myinsecurehost:5000 + 127.0.0.0/8 + You can also specify the output format: $ docker info --format '{{json .}}'