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