Log and print original error for start
Currently `start` will hide some errors and throw a consolidated error, which will make it hard to debug because developer can't find the original error. This commit allow daemon to log original errors first. Signed-off-by: Zhang Wei <zhangwei555@huawei.com> Upstream-commit: b4740e3021a39a502ffc82f0f70e9b7ed2f0875f Component: engine
This commit is contained in:
@ -7,6 +7,8 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/errors"
|
||||
@ -131,24 +133,24 @@ func (daemon *Daemon) containerStart(container *container.Container) (err error)
|
||||
}
|
||||
|
||||
if err := daemon.containerd.Create(container.ID, *spec, libcontainerd.WithRestartManager(container.RestartManager(true))); err != nil {
|
||||
errDesc := grpc.ErrorDesc(err)
|
||||
logrus.Errorf("Create container failed with error: %s", errDesc)
|
||||
// if we receive an internal error from the initial start of a container then lets
|
||||
// return it instead of entering the restart loop
|
||||
// set to 127 for container cmd not found/does not exist)
|
||||
if strings.Contains(err.Error(), "executable file not found") ||
|
||||
strings.Contains(err.Error(), "no such file or directory") ||
|
||||
strings.Contains(err.Error(), "system cannot find the file specified") {
|
||||
if strings.Contains(errDesc, "executable file not found") ||
|
||||
strings.Contains(errDesc, "no such file or directory") ||
|
||||
strings.Contains(errDesc, "system cannot find the file specified") {
|
||||
container.ExitCode = 127
|
||||
err = fmt.Errorf("Container command '%s' not found or does not exist", container.Path)
|
||||
}
|
||||
// set to 126 for container cmd can't be invoked errors
|
||||
if strings.Contains(err.Error(), syscall.EACCES.Error()) {
|
||||
if strings.Contains(errDesc, syscall.EACCES.Error()) {
|
||||
container.ExitCode = 126
|
||||
err = fmt.Errorf("Container command '%s' could not be invoked", container.Path)
|
||||
}
|
||||
|
||||
container.Reset(false)
|
||||
|
||||
return err
|
||||
return fmt.Errorf("%s", errDesc)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user