From 167601e85850aa58df96f9d0796f9c26ed2d6fa4 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 10 Sep 2013 20:21:15 +0200 Subject: [PATCH] Runtime: Automatically use docker-init if it exists In some builds the main docker binary is not statically linked, and as such not usable in as the .dockerinit binary, for those cases we look for a separately shipped docker-init binary and use that instead. --- runtime.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/runtime.go b/runtime.go index d77ecca722..ad4672b040 100644 --- a/runtime.go +++ b/runtime.go @@ -10,6 +10,7 @@ import ( "os" "os/exec" "path" + "path/filepath" "sort" "strings" "time" @@ -42,7 +43,17 @@ type Runtime struct { var sysInitPath string func init() { - sysInitPath = utils.SelfPath() + selfPath := utils.SelfPath() + + // If we have a separate docker-init, use that, otherwise use the + // main docker binary + dir := filepath.Dir(selfPath) + dockerInitPath := filepath.Join(dir, "docker-init") + if _, err := os.Stat(dockerInitPath); err != nil { + sysInitPath = selfPath + } else { + sysInitPath = dockerInitPath + } } // List returns an array of all containers registered in the runtime.