github.com/endocode/docker@v1.4.2-0.20160113120958-46eb4700391e/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, " Init SHA1: %s\n", info.InitSha1) 78 fmt.Fprintf(cli.out, " Init Path: %s\n", info.InitPath) 79 fmt.Fprintf(cli.out, " Docker Root Dir: %s\n", info.DockerRootDir) 80 } 81 82 ioutils.FprintfIfNotEmpty(cli.out, "Http Proxy: %s\n", info.HTTPProxy) 83 ioutils.FprintfIfNotEmpty(cli.out, "Https Proxy: %s\n", info.HTTPSProxy) 84 ioutils.FprintfIfNotEmpty(cli.out, "No Proxy: %s\n", info.NoProxy) 85 86 if info.IndexServerAddress != "" { 87 u := cli.configFile.AuthConfigs[info.IndexServerAddress].Username 88 if len(u) > 0 { 89 fmt.Fprintf(cli.out, "Username: %v\n", u) 90 fmt.Fprintf(cli.out, "Registry: %v\n", info.IndexServerAddress) 91 } 92 } 93 94 // Only output these warnings if the server does not support these features 95 if info.OSType != "windows" { 96 if !info.MemoryLimit { 97 fmt.Fprintln(cli.err, "WARNING: No memory limit support") 98 } 99 if !info.SwapLimit { 100 fmt.Fprintln(cli.err, "WARNING: No swap limit support") 101 } 102 if !info.OomKillDisable { 103 fmt.Fprintln(cli.err, "WARNING: No oom kill disable support") 104 } 105 if !info.CPUCfsQuota { 106 fmt.Fprintln(cli.err, "WARNING: No cpu cfs quota support") 107 } 108 if !info.CPUCfsPeriod { 109 fmt.Fprintln(cli.err, "WARNING: No cpu cfs period support") 110 } 111 if !info.CPUShares { 112 fmt.Fprintln(cli.err, "WARNING: No cpu shares support") 113 } 114 if !info.CPUSet { 115 fmt.Fprintln(cli.err, "WARNING: No cpuset support") 116 } 117 if !info.IPv4Forwarding { 118 fmt.Fprintln(cli.err, "WARNING: IPv4 forwarding is disabled") 119 } 120 if !info.BridgeNfIptables { 121 fmt.Fprintln(cli.err, "WARNING: bridge-nf-call-iptables is disabled") 122 } 123 if !info.BridgeNfIP6tables { 124 fmt.Fprintln(cli.err, "WARNING: bridge-nf-call-ip6tables is disabled") 125 } 126 } 127 128 if info.Labels != nil { 129 fmt.Fprintln(cli.out, "Labels:") 130 for _, attribute := range info.Labels { 131 fmt.Fprintf(cli.out, " %s\n", attribute) 132 } 133 } 134 135 ioutils.FprintfIfTrue(cli.out, "Experimental: %v\n", info.ExperimentalBuild) 136 if info.ClusterStore != "" { 137 fmt.Fprintf(cli.out, "Cluster store: %s\n", info.ClusterStore) 138 } 139 140 if info.ClusterAdvertise != "" { 141 fmt.Fprintf(cli.out, "Cluster advertise: %s\n", info.ClusterAdvertise) 142 } 143 return nil 144 }