1
0
mirror of https://github.com/docker/cli.git synced 2026-01-23 15:21:32 +03:00

Merge pull request #15446 from cpuguy83/better_err_on_exec_err

Return better errors from exec
Upstream-commit: d3198fa8c4f704a2ddd4d876003757b30a61c00c
Component: engine
This commit is contained in:
Jessie Frazelle
2015-08-12 11:13:29 -07:00
2 changed files with 18 additions and 21 deletions

View File

@@ -175,7 +175,6 @@ func (d *Daemon) ContainerExecCreate(config *runconfig.ExecConfig) (string, erro
}
func (d *Daemon) ContainerExecStart(execName string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error {
var (
cStdin io.ReadCloser
cStdout, cStderr io.Writer
@@ -246,12 +245,18 @@ func (d *Daemon) ContainerExecStart(execName string, stdin io.ReadCloser, stdout
if err != nil {
return fmt.Errorf("attach failed with error: %s", err)
}
break
return nil
case err := <-execErr:
if err == nil {
return nil
}
// Maybe the container stopped while we were trying to exec
if !container.IsRunning() {
return fmt.Errorf("container stopped while running exec")
}
return err
}
return nil
}
func (d *Daemon) Exec(c *Container, execConfig *execConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {