diff --git a/core/oci.go b/core/oci.go index 9d4e3256..f9d301bb 100644 --- a/core/oci.go +++ b/core/oci.go @@ -78,6 +78,7 @@ func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir s return err } + pulledImage := false // pull image if !strings.HasPrefix(imageRecipe.From, "localhost/") { err = pullImageWithProgressbar(pt, buildImageName, imageRecipe) @@ -85,6 +86,7 @@ func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir s PrintVerboseErr("OciExportRootFs", 6.1, err) return err } + pulledImage = true } // build image @@ -94,6 +96,15 @@ func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir s return err } + if pulledImage { + // This is safe because BuildContainerFile layers on top of the base image + // So this won't delete the actual layers, only the image reference + _, err = pt.Store.DeleteImage(imageRecipe.From, true) + if err != nil { + PrintVerboseWarn("OciExportRootFs", 7.5, "could not delete downloaded image", err) + } + } + // mount image mountDir, err := pt.MountImage(imageBuild.TopLayer) if err != nil {