From f02d766f9a93bf86c6473eb2772bc239ffaa1cd6 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Thu, 5 Dec 2013 02:14:15 -0700 Subject: [PATCH] Add dockerinit SHA1 and path to "docker info" when debug mode is enabled --- commands.go | 7 +++++++ server.go | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/commands.go b/commands.go index ef6dce6bd5..638af7f514 100644 --- a/commands.go +++ b/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 { diff --git a/server.go b/server.go index 9b492a2927..7aa03a0374 100644 --- a/server.go +++ b/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