github.com/tsuna/docker@v1.7.0-rc3/api/client/info.go (about) 1 package client 2 3 import ( 4 "encoding/json" 5 "fmt" 6 7 "github.com/docker/docker/api/types" 8 "github.com/docker/docker/pkg/ioutils" 9 flag "github.com/docker/docker/pkg/mflag" 10 "github.com/docker/docker/pkg/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", "", "Display system-wide information", true) 18 cmd.Require(flag.Exact, 0) 19 cmd.ParseFlags(args, true) 20 21 rdr, _, err := cli.call("GET", "/info", nil, nil) 22 if err != nil { 23 return err 24 } 25 26 info := &types.Info{} 27 if err := json.NewDecoder(rdr).Decode(info); err != nil { 28 return fmt.Errorf("Error reading remote info: %v", err) 29 } 30 31 fmt.Fprintf(cli.out, "Containers: %d\n", info.Containers) 32 fmt.Fprintf(cli.out, "Images: %d\n", info.Images) 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 } 39 ioutils.FprintfIfNotEmpty(cli.out, "Execution Driver: %s\n", info.ExecutionDriver) 40 ioutils.FprintfIfNotEmpty(cli.out, "Logging Driver: %s\n", info.LoggingDriver) 41 ioutils.FprintfIfNotEmpty(cli.out, "Kernel Version: %s\n", info.KernelVersion) 42 ioutils.FprintfIfNotEmpty(cli.out, "Operating System: %s\n", info.OperatingSystem) 43 fmt.Fprintf(cli.out, "CPUs: %d\n", info.NCPU) 44 fmt.Fprintf(cli.out, "Total Memory: %s\n", units.BytesSize(float64(info.MemTotal))) 45 ioutils.FprintfIfNotEmpty(cli.out, "Name: %s\n", info.Name) 46 ioutils.FprintfIfNotEmpty(cli.out, "ID: %s\n", info.ID) 47 48 if info.Debug { 49 fmt.Fprintf(cli.out, "Debug mode (server): %v\n", info.Debug) 50 fmt.Fprintf(cli.out, "File Descriptors: %d\n", info.NFd) 51 fmt.Fprintf(cli.out, "Goroutines: %d\n", info.NGoroutines) 52 fmt.Fprintf(cli.out, "System Time: %s\n", info.SystemTime) 53 fmt.Fprintf(cli.out, "EventsListeners: %d\n", info.NEventsListener) 54 fmt.Fprintf(cli.out, "Init SHA1: %s\n", info.InitSha1) 55 fmt.Fprintf(cli.out, "Init Path: %s\n", info.InitPath) 56 fmt.Fprintf(cli.out, "Docker Root Dir: %s\n", info.DockerRootDir) 57 } 58 59 ioutils.FprintfIfNotEmpty(cli.out, "Http Proxy: %s\n", info.HttpProxy) 60 ioutils.FprintfIfNotEmpty(cli.out, "Https Proxy: %s\n", info.HttpsProxy) 61 ioutils.FprintfIfNotEmpty(cli.out, "No Proxy: %s\n", info.NoProxy) 62 63 if info.IndexServerAddress != "" { 64 u := cli.configFile.AuthConfigs[info.IndexServerAddress].Username 65 if len(u) > 0 { 66 fmt.Fprintf(cli.out, "Username: %v\n", u) 67 fmt.Fprintf(cli.out, "Registry: %v\n", info.IndexServerAddress) 68 } 69 } 70 if !info.MemoryLimit { 71 fmt.Fprintf(cli.err, "WARNING: No memory limit support\n") 72 } 73 if !info.SwapLimit { 74 fmt.Fprintf(cli.err, "WARNING: No swap limit support\n") 75 } 76 if !info.IPv4Forwarding { 77 fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n") 78 } 79 if info.Labels != nil { 80 fmt.Fprintln(cli.out, "Labels:") 81 for _, attribute := range info.Labels { 82 fmt.Fprintf(cli.out, " %s\n", attribute) 83 } 84 } 85 86 if info.ExperimentalBuild { 87 fmt.Fprintf(cli.out, "Experimental: true\n") 88 } 89 90 return nil 91 }