github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/api/client/info.go (about) 1 package client 2 3 import ( 4 "fmt" 5 6 Cli "github.com/docker/docker/cli" 7 "github.com/docker/docker/pkg/ioutils" 8 flag "github.com/docker/docker/pkg/mflag" 9 "github.com/docker/go-units" 10 ) 11 12 // CmdInfo displays system-wide information. 13 // 14 // Usage: docker info 15 func (cli *DockerCli) CmdInfo(args ...string) error { 16 cmd := Cli.Subcmd("info", nil, Cli.DockerCommands["info"].Description, true) 17 cmd.Require(flag.Exact, 0) 18 19 cmd.ParseFlags(args, true) 20 21 info, err := cli.client.Info() 22 if err != nil { 23 return err 24 } 25 26 fmt.Fprintf(cli.out, "Containers: %d\n", info.Containers) 27 fmt.Fprintf(cli.out, "Images: %d\n", info.Images) 28 ioutils.FprintfIfNotEmpty(cli.out, "Server Version: %s\n", info.ServerVersion) 29 ioutils.FprintfIfNotEmpty(cli.out, "Storage Driver: %s\n", info.Driver) 30 if info.DriverStatus != nil { 31 for _, pair := range info.DriverStatus { 32 fmt.Fprintf(cli.out, " %s: %s\n", pair[0], pair[1]) 33 34 // print a warning if devicemapper is using a loopback file 35 if pair[0] == "Data loop file" { 36 fmt.Fprintln(cli.err, " WARNING: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.") 37 } 38 } 39 40 } 41 ioutils.FprintfIfNotEmpty(cli.out, "Execution Driver: %s\n", info.ExecutionDriver) 42 ioutils.FprintfIfNotEmpty(cli.out, "Logging Driver: %s\n", info.LoggingDriver) 43 44 fmt.Fprintf(cli.out, "Plugins: \n") 45 fmt.Fprintf(cli.out, " Volume:") 46 for _, driver := range info.Plugins.Volume { 47 fmt.Fprintf(cli.out, " %s", driver) 48 } 49 fmt.Fprintf(cli.out, "\n") 50 fmt.Fprintf(cli.out, " Network:") 51 for _, driver := range info.Plugins.Network { 52 fmt.Fprintf(cli.out, " %s", driver) 53 } 54 fmt.Fprintf(cli.out, "\n") 55 56 ioutils.FprintfIfNotEmpty(cli.out, "Kernel Version: %s\n", info.KernelVersion) 57 ioutils.FprintfIfNotEmpty(cli.out, "Operating System: %s\n", info.OperatingSystem) 58 ioutils.FprintfIfNotEmpty(cli.out, "OSType: %s\n", info.OSType) 59 ioutils.FprintfIfNotEmpty(cli.out, "Architecture: %s\n", info.Architecture) 60 fmt.Fprintf(cli.out, "CPUs: %d\n", info.NCPU) 61 fmt.Fprintf(cli.out, "Total Memory: %s\n", units.BytesSize(float64(info.MemTotal))) 62 ioutils.FprintfIfNotEmpty(cli.out, "Name: %s\n", info.Name) 63 ioutils.FprintfIfNotEmpty(cli.out, "ID: %s\n", info.ID) 64 65 if info.Debug { 66 fmt.Fprintf(cli.out, "Debug mode (server): %v\n", info.Debug) 67 fmt.Fprintf(cli.out, " File Descriptors: %d\n", info.NFd) 68 fmt.Fprintf(cli.out, " Goroutines: %d\n", info.NGoroutines) 69 fmt.Fprintf(cli.out, " System Time: %s\n", info.SystemTime) 70 fmt.Fprintf(cli.out, " EventsListeners: %d\n", info.NEventsListener) 71 fmt.Fprintf(cli.out, " Init SHA1: %s\n", info.InitSha1) 72 fmt.Fprintf(cli.out, " Init Path: %s\n", info.InitPath) 73 fmt.Fprintf(cli.out, " Docker Root Dir: %s\n", info.DockerRootDir) 74 } 75 76 ioutils.FprintfIfNotEmpty(cli.out, "Http Proxy: %s\n", info.HTTPProxy) 77 ioutils.FprintfIfNotEmpty(cli.out, "Https Proxy: %s\n", info.HTTPSProxy) 78 ioutils.FprintfIfNotEmpty(cli.out, "No Proxy: %s\n", info.NoProxy) 79 80 if info.IndexServerAddress != "" { 81 u := cli.configFile.AuthConfigs[info.IndexServerAddress].Username 82 if len(u) > 0 { 83 fmt.Fprintf(cli.out, "Username: %v\n", u) 84 fmt.Fprintf(cli.out, "Registry: %v\n", info.IndexServerAddress) 85 } 86 } 87 88 // Only output these warnings if the server does not support these features 89 if info.OSType != "windows" { 90 if !info.MemoryLimit { 91 fmt.Fprintln(cli.err, "WARNING: No memory limit support") 92 } 93 if !info.SwapLimit { 94 fmt.Fprintln(cli.err, "WARNING: No swap limit support") 95 } 96 if !info.OomKillDisable { 97 fmt.Fprintln(cli.err, "WARNING: No oom kill disable support") 98 } 99 if !info.CPUCfsQuota { 100 fmt.Fprintln(cli.err, "WARNING: No cpu cfs quota support") 101 } 102 if !info.CPUCfsPeriod { 103 fmt.Fprintln(cli.err, "WARNING: No cpu cfs period support") 104 } 105 if !info.CPUShares { 106 fmt.Fprintln(cli.err, "WARNING: No cpu shares support") 107 } 108 if !info.CPUSet { 109 fmt.Fprintln(cli.err, "WARNING: No cpuset support") 110 } 111 if !info.IPv4Forwarding { 112 fmt.Fprintln(cli.err, "WARNING: IPv4 forwarding is disabled") 113 } 114 if !info.BridgeNfIptables { 115 fmt.Fprintln(cli.err, "WARNING: bridge-nf-call-iptables is disabled") 116 } 117 if !info.BridgeNfIP6tables { 118 fmt.Fprintln(cli.err, "WARNING: bridge-nf-call-ip6tables is disabled") 119 } 120 } 121 122 if info.Labels != nil { 123 fmt.Fprintln(cli.out, "Labels:") 124 for _, attribute := range info.Labels { 125 fmt.Fprintf(cli.out, " %s\n", attribute) 126 } 127 } 128 129 ioutils.FprintfIfTrue(cli.out, "Experimental: %v\n", info.ExperimentalBuild) 130 if info.ClusterStore != "" { 131 fmt.Fprintf(cli.out, "Cluster store: %s\n", info.ClusterStore) 132 } 133 134 if info.ClusterAdvertise != "" { 135 fmt.Fprintf(cli.out, "Cluster advertise: %s\n", info.ClusterAdvertise) 136 } 137 return nil 138 }