Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #193 from ijc/bugfix-191
Browse files Browse the repository at this point in the history
Defer dockerRm until we are finished with the contents
  • Loading branch information
justincormack authored Dec 13, 2017
2 parents ebd7228 + 307f13b commit d9d2a91
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/moby/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func tarPrefix(path string, tw tarWriter) error {
}

// ImageTar takes a Docker image and outputs it to a tar stream
func ImageTar(ref *reference.Spec, prefix string, tw tarWriter, trust bool, pull bool, resolv string) error {
func ImageTar(ref *reference.Spec, prefix string, tw tarWriter, trust bool, pull bool, resolv string) (e error) {
log.Debugf("image tar: %s %s", ref, prefix)
if prefix != "" && prefix[len(prefix)-1] != byte('/') {
return fmt.Errorf("prefix does not end with /: %s", prefix)
Expand Down Expand Up @@ -119,12 +119,13 @@ func ImageTar(ref *reference.Spec, prefix string, tw tarWriter, trust bool, pull
if err != nil {
return fmt.Errorf("Failed to docker export container from container %s: %v", container, err)
}
defer contents.Close()
defer func() {
contents.Close()

err = dockerRm(container)
if err != nil {
return fmt.Errorf("Failed to docker rm container %s: %v", container, err)
}
if err := dockerRm(container); e == nil && err != nil {
e = fmt.Errorf("Failed to docker rm container %s: %v", container, err)
}
}()

// now we need to filter out some files from the resulting tar archive

Expand Down

0 comments on commit d9d2a91

Please sign in to comment.