Browse Source

Add dockerinit SHA1 and path to "docker info" when debug mode is enabled

Tianon Gravi 11 years ago
parent
commit
f02d766f9a
2 changed files with 16 additions and 0 deletions
  1. 7 0
      commands.go
  2. 9 0
      server.go

+ 7 - 0
commands.go

@@ -469,6 +469,13 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
 		fmt.Fprintf(cli.out, "LXC Version: %s\n", remoteInfo.Get("LXCVersion"))
 		fmt.Fprintf(cli.out, "EventsListeners: %d\n", remoteInfo.GetInt("NEventsListener"))
 		fmt.Fprintf(cli.out, "Kernel Version: %s\n", remoteInfo.Get("KernelVersion"))
+
+		if initSha1 := remoteInfo.Get("InitSha1"); initSha1 != "" {
+			fmt.Fprintf(cli.out, "Init SHA1: %s\n", initSha1)
+		}
+		if initPath := remoteInfo.Get("InitPath"); initPath != "" {
+			fmt.Fprintf(cli.out, "Init Path: %s\n", initPath)
+		}
 	}
 
 	if len(remoteInfo.GetList("IndexServerAddress")) != 0 {

+ 9 - 0
server.go

@@ -634,6 +634,13 @@ func (srv *Server) DockerInfo(job *engine.Job) engine.Status {
 		kernelVersion = kv.String()
 	}
 
+	// if we still have the original dockerinit binary from before we copied it locally, let's return the path to that, since that's more intuitive (the copied path is trivial to derive by hand given VERSION)
+	initPath := utils.DockerInitPath("")
+	if initPath == "" {
+		// if that fails, we'll just return the path from the runtime
+		initPath = srv.runtime.sysInitPath
+	}
+
 	v := &engine.Env{}
 	v.SetInt("Containers", len(srv.runtime.List()))
 	v.SetInt("Images", imgcount)
@@ -649,6 +656,8 @@ func (srv *Server) DockerInfo(job *engine.Job) engine.Status {
 	v.SetInt("NEventsListener", len(srv.events))
 	v.Set("KernelVersion", kernelVersion)
 	v.Set("IndexServerAddress", auth.IndexServerAddress())
+	v.Set("InitSha1", utils.INITSHA1)
+	v.Set("InitPath", initPath)
 	if _, err := v.WriteTo(job.Stdout); err != nil {
 		job.Error(err)
 		return engine.StatusErr