print stderr on docker import failure

This commit is contained in:
Matthew Hooker 2017-02-09 20:39:55 -08:00
parent e04f87effe
commit c41e32dbc1
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
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