Merge pull request #4529 from mitchellh/difout

print stderr on docker import failure
This commit is contained in:
Matthew Hooker 2017-02-09 20:46:31 -08:00 committed by GitHub
commit a34e9684e5
1 changed files with 3 additions and 3 deletions

View File

@ -97,9 +97,10 @@ func (d *DockerDriver) Export(id string, dst io.Writer) error {
} }
func (d *DockerDriver) Import(path string, repo string) (string, error) { func (d *DockerDriver) Import(path string, repo string) (string, error) {
var stdout bytes.Buffer var stdout, stderr bytes.Buffer
cmd := exec.Command("docker", "import", "-", repo) cmd := exec.Command("docker", "import", "-", repo)
cmd.Stdout = &stdout cmd.Stdout = &stdout
cmd.Stderr = &stderr
stdin, err := cmd.StdinPipe() stdin, err := cmd.StdinPipe()
if err != nil { if err != nil {
return "", err return "", err
@ -122,8 +123,7 @@ func (d *DockerDriver) Import(path string, repo string) (string, error) {
}() }()
if err := cmd.Wait(); err != nil { if err := cmd.Wait(); err != nil {
err = fmt.Errorf("Error importing container: %s", err) return "", fmt.Errorf("Error importing container: %s\n\nStderr: %s", err, stderr.String())
return "", err
} }
return strings.TrimSpace(stdout.String()), nil return strings.TrimSpace(stdout.String()), nil