mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-22 10:31:35 +00:00
Merge pull request #193 from ijc/bugfix-191
Defer dockerRm until we are finished with the contents
This commit is contained in:
commit
d9d2a91780
@ -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)
|
||||
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user