2015-03-24 23:57:23 -04:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
2015-04-10 13:26:30 -04:00
|
|
|
"encoding/json"
|
2015-03-24 23:57:23 -04:00
|
|
|
"fmt"
|
|
|
|
|
2015-04-10 13:26:30 -04:00
|
|
|
"github.com/docker/docker/api/types"
|
2015-05-05 00:18:28 -04:00
|
|
|
Cli "github.com/docker/docker/cli"
|
2015-07-09 22:05:50 -04:00
|
|
|
"github.com/docker/docker/pkg/httputils"
|
2015-05-29 19:48:02 -04:00
|
|
|
"github.com/docker/docker/pkg/ioutils"
|
2015-03-24 23:57:23 -04:00
|
|
|
flag "github.com/docker/docker/pkg/mflag"
|
|
|
|
"github.com/docker/docker/pkg/units"
|
|
|
|
)
|
|
|
|
|
2015-03-25 13:34:41 -04:00
|
|
|
// CmdInfo displays system-wide information.
|
|
|
|
//
|
|
|
|
// Usage: docker info
|
2015-03-24 23:57:23 -04:00
|
|
|
func (cli *DockerCli) CmdInfo(args ...string) error {
|
2015-05-05 00:18:28 -04:00
|
|
|
cmd := Cli.Subcmd("info", nil, "Display system-wide information", true)
|
2015-03-24 23:57:23 -04:00
|
|
|
cmd.Require(flag.Exact, 0)
|
2015-07-03 05:26:09 -04:00
|
|
|
|
2015-05-23 11:57:50 -04:00
|
|
|
cmd.ParseFlags(args, true)
|
2015-03-24 23:57:23 -04:00
|
|
|
|
2015-07-09 22:05:50 -04:00
|
|
|
serverResp, err := cli.call("GET", "/info", nil, nil)
|
2015-03-24 23:57:23 -04:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-07-09 22:05:50 -04:00
|
|
|
defer serverResp.body.Close()
|
2015-07-03 02:19:23 -04:00
|
|
|
|
2015-04-10 13:26:30 -04:00
|
|
|
info := &types.Info{}
|
2015-07-09 22:05:50 -04:00
|
|
|
if err := json.NewDecoder(serverResp.body).Decode(info); err != nil {
|
2015-04-10 13:26:30 -04:00
|
|
|
return fmt.Errorf("Error reading remote info: %v", err)
|
2015-03-24 23:57:23 -04:00
|
|
|
}
|
|
|
|
|
2015-04-10 13:26:30 -04:00
|
|
|
fmt.Fprintf(cli.out, "Containers: %d\n", info.Containers)
|
|
|
|
fmt.Fprintf(cli.out, "Images: %d\n", info.Images)
|
2015-05-29 19:48:02 -04:00
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "Storage Driver: %s\n", info.Driver)
|
2015-04-10 13:26:30 -04:00
|
|
|
if info.DriverStatus != nil {
|
|
|
|
for _, pair := range info.DriverStatus {
|
2015-03-24 23:57:23 -04:00
|
|
|
fmt.Fprintf(cli.out, " %s: %s\n", pair[0], pair[1])
|
|
|
|
}
|
|
|
|
}
|
2015-05-29 19:48:02 -04:00
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "Execution Driver: %s\n", info.ExecutionDriver)
|
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "Logging Driver: %s\n", info.LoggingDriver)
|
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "Kernel Version: %s\n", info.KernelVersion)
|
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "Operating System: %s\n", info.OperatingSystem)
|
2015-04-10 13:26:30 -04:00
|
|
|
fmt.Fprintf(cli.out, "CPUs: %d\n", info.NCPU)
|
|
|
|
fmt.Fprintf(cli.out, "Total Memory: %s\n", units.BytesSize(float64(info.MemTotal)))
|
2015-05-29 19:48:02 -04:00
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "Name: %s\n", info.Name)
|
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "ID: %s\n", info.ID)
|
2015-03-24 23:57:23 -04:00
|
|
|
|
2015-03-31 16:49:41 -04:00
|
|
|
if info.Debug {
|
2015-04-10 13:26:30 -04:00
|
|
|
fmt.Fprintf(cli.out, "Debug mode (server): %v\n", info.Debug)
|
|
|
|
fmt.Fprintf(cli.out, "File Descriptors: %d\n", info.NFd)
|
|
|
|
fmt.Fprintf(cli.out, "Goroutines: %d\n", info.NGoroutines)
|
|
|
|
fmt.Fprintf(cli.out, "System Time: %s\n", info.SystemTime)
|
|
|
|
fmt.Fprintf(cli.out, "EventsListeners: %d\n", info.NEventsListener)
|
|
|
|
fmt.Fprintf(cli.out, "Init SHA1: %s\n", info.InitSha1)
|
|
|
|
fmt.Fprintf(cli.out, "Init Path: %s\n", info.InitPath)
|
|
|
|
fmt.Fprintf(cli.out, "Docker Root Dir: %s\n", info.DockerRootDir)
|
2015-03-24 23:57:23 -04:00
|
|
|
}
|
2015-04-10 13:26:30 -04:00
|
|
|
|
2015-07-23 05:40:54 -04:00
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "Http Proxy: %s\n", info.HTTPProxy)
|
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "Https Proxy: %s\n", info.HTTPSProxy)
|
2015-05-29 19:48:02 -04:00
|
|
|
ioutils.FprintfIfNotEmpty(cli.out, "No Proxy: %s\n", info.NoProxy)
|
2015-04-10 13:26:30 -04:00
|
|
|
|
|
|
|
if info.IndexServerAddress != "" {
|
2015-04-01 18:39:37 -04:00
|
|
|
u := cli.configFile.AuthConfigs[info.IndexServerAddress].Username
|
2015-03-24 23:57:23 -04:00
|
|
|
if len(u) > 0 {
|
|
|
|
fmt.Fprintf(cli.out, "Username: %v\n", u)
|
2015-04-10 13:26:30 -04:00
|
|
|
fmt.Fprintf(cli.out, "Registry: %v\n", info.IndexServerAddress)
|
2015-03-24 23:57:23 -04:00
|
|
|
}
|
|
|
|
}
|
2015-07-09 22:05:50 -04:00
|
|
|
// Only output these warnings if the server supports these features
|
|
|
|
if h, err := httputils.ParseServerHeader(serverResp.header.Get("Server")); err == nil {
|
|
|
|
if h.OS != "windows" {
|
|
|
|
if !info.MemoryLimit {
|
|
|
|
fmt.Fprintf(cli.err, "WARNING: No memory limit support\n")
|
|
|
|
}
|
|
|
|
if !info.SwapLimit {
|
|
|
|
fmt.Fprintf(cli.err, "WARNING: No swap limit support\n")
|
|
|
|
}
|
|
|
|
if !info.IPv4Forwarding {
|
2015-08-08 01:06:59 -04:00
|
|
|
fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled\n")
|
2015-07-09 22:05:50 -04:00
|
|
|
}
|
|
|
|
if !info.BridgeNfIptables {
|
|
|
|
fmt.Fprintf(cli.err, "WARNING: bridge-nf-call-iptables is disabled\n")
|
|
|
|
}
|
2015-07-23 05:40:54 -04:00
|
|
|
if !info.BridgeNfIP6tables {
|
2015-07-09 22:05:50 -04:00
|
|
|
fmt.Fprintf(cli.err, "WARNING: bridge-nf-call-ip6tables is disabled\n")
|
|
|
|
}
|
|
|
|
}
|
2015-06-16 21:19:11 -04:00
|
|
|
}
|
2015-07-09 22:05:50 -04:00
|
|
|
|
2015-04-10 13:26:30 -04:00
|
|
|
if info.Labels != nil {
|
2015-03-24 23:57:23 -04:00
|
|
|
fmt.Fprintln(cli.out, "Labels:")
|
2015-04-10 13:26:30 -04:00
|
|
|
for _, attribute := range info.Labels {
|
2015-03-24 23:57:23 -04:00
|
|
|
fmt.Fprintf(cli.out, " %s\n", attribute)
|
|
|
|
}
|
|
|
|
}
|
2015-05-21 13:48:36 -04:00
|
|
|
|
|
|
|
if info.ExperimentalBuild {
|
|
|
|
fmt.Fprintf(cli.out, "Experimental: true\n")
|
|
|
|
}
|
2015-03-24 23:57:23 -04:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|