diff --git a/builder/remotecontext/detect.go b/builder/remotecontext/detect.go index 49b196ed7b..144eb570ab 100644 --- a/builder/remotecontext/detect.go +++ b/builder/remotecontext/detect.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "runtime" "strings" "github.com/containerd/continuity/driver" @@ -173,6 +174,9 @@ func StatAt(remote builder.Source, path string) (os.FileInfo, error) { func FullPath(remote builder.Source, path string) (string, error) { fullPath, err := remote.Root().ResolveScopedPath(path, true) if err != nil { + if runtime.GOOS == "windows" { + return "", fmt.Errorf("failed to resolve scoped path %s (%s): %s. Possible cause is a forbidden path outside the build context", path, fullPath, err) + } return "", fmt.Errorf("Forbidden path outside the build context: %s (%s)", path, fullPath) // backwards compat with old error } return fullPath, nil diff --git a/daemon/graphdriver/lcow/lcow_svm.go b/daemon/graphdriver/lcow/lcow_svm.go index 72843b1a74..fdb0553dee 100644 --- a/daemon/graphdriver/lcow/lcow_svm.go +++ b/daemon/graphdriver/lcow/lcow_svm.go @@ -3,6 +3,7 @@ package lcow // import "github.com/docker/docker/daemon/graphdriver/lcow" import ( + "bytes" "errors" "fmt" "io" @@ -385,7 +386,15 @@ func (svm *serviceVM) deleteUnionMount(mountName string, disks ...hcsshim.Mapped } func (svm *serviceVM) runProcess(command string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error { - process, err := svm.config.RunProcess(command, stdin, stdout, stderr) + var process hcsshim.Process + var err error + errOut := &bytes.Buffer{} + + if stderr != nil { + process, err = svm.config.RunProcess(command, stdin, stdout, stderr) + } else { + process, err = svm.config.RunProcess(command, stdin, stdout, errOut) + } if err != nil { return err } @@ -398,7 +407,12 @@ func (svm *serviceVM) runProcess(command string, stdin io.Reader, stdout io.Writ } if exitCode != 0 { - return fmt.Errorf("svm.runProcess: command %s failed with exit code %d", command, exitCode) + // If the caller isn't explicitly capturing stderr output, then capture it here instead. + e := fmt.Sprintf("svm.runProcess: command %s failed with exit code %d", command, exitCode) + if stderr == nil { + e = fmt.Sprintf("%s. (%s)", e, errOut.String()) + } + return fmt.Errorf(e) } return nil }