From f30f823bf50de6581f547aee842286584c4b6990 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Fri, 28 Feb 2014 00:32:58 +0000 Subject: [PATCH] fix docker info with lxc 1.0.0 Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) --- execdriver/lxc/driver.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/execdriver/lxc/driver.go b/execdriver/lxc/driver.go index f1c93af789..8f8dcbda17 100644 --- a/execdriver/lxc/driver.go +++ b/execdriver/lxc/driver.go @@ -206,11 +206,20 @@ func (d *driver) Restore(c *execdriver.Command) error { } func (d *driver) version() string { - version := "" - if output, err := exec.Command("lxc-version").CombinedOutput(); err == nil { - outputStr := string(output) - if len(strings.SplitN(outputStr, ":", 2)) == 2 { - version = strings.TrimSpace(strings.SplitN(outputStr, ":", 2)[1]) + var ( + version string + output []byte + err error + ) + if _, errPath := exec.LookPath("lxc-version"); errPath == nil { + output, err = exec.Command("lxc-version").CombinedOutput() + } else { + output, err = exec.Command("lxc-start", "--version").CombinedOutput() + } + if err == nil { + version = strings.TrimSpace(string(output)) + if parts := strings.SplitN(version, ":", 2); len(parts) == 2 { + version = strings.TrimSpace(parts[1]) } } return version