From ab30e19b96ce498c8a7de748e197f12b5550a7b2 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 23 Sep 2014 21:47:33 +0000 Subject: [PATCH] Improve error for docker exec & LXC Signed-off-by: Victor Vieux --- daemon/exec.go | 6 ++++++ daemon/execdriver/lxc/driver.go | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/daemon/exec.go b/daemon/exec.go index 02f4804605..483a6d7d01 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -6,9 +6,11 @@ import ( "fmt" "io" "io/ioutil" + "strings" "sync" "github.com/docker/docker/daemon/execdriver" + "github.com/docker/docker/daemon/execdriver/lxc" "github.com/docker/docker/engine" "github.com/docker/docker/pkg/broadcastwriter" "github.com/docker/docker/pkg/ioutils" @@ -103,6 +105,10 @@ func (d *Daemon) ContainerExecCreate(job *engine.Job) engine.Status { return job.Errorf("Usage: %s [options] container command [args]", job.Name) } + if strings.HasPrefix(d.execDriver.Name(), lxc.DriverName) { + return job.Error(lxc.ErrExec) + } + var name = job.Args[0] container, err := d.getActiveContainer(name) diff --git a/daemon/execdriver/lxc/driver.go b/daemon/execdriver/lxc/driver.go index 13884fc699..9ac75dbdde 100644 --- a/daemon/execdriver/lxc/driver.go +++ b/daemon/execdriver/lxc/driver.go @@ -2,6 +2,7 @@ package lxc import ( "encoding/json" + "errors" "fmt" "io" "io/ioutil" @@ -27,6 +28,8 @@ import ( const DriverName = "lxc" +var ErrExec = errors.New("Unsupported: Exec is not supported by the lxc driver") + type driver struct { root string // root path for the driver to use initPath string @@ -529,5 +532,5 @@ func (t *TtyConsole) Close() error { } func (d *driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) { - return -1, fmt.Errorf("Unsupported: Exec is not supported by the lxc driver") + return -1, ErrExec }