2
0
mirror of https://github.com/linka-cloud/d2vm.git synced 2025-12-14 15:03:12 +00:00

add keep-cache option to preserve intermediate docker images

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
2023-02-28 12:02:57 +01:00
committed by Adphi
parent 4780228c95
commit be88bc29f5
10 changed files with 53 additions and 13 deletions

View File

@@ -65,13 +65,17 @@ func Convert(ctx context.Context, img string, opts ...ConvertOption) error {
if err := docker.Build(ctx, imgUUID, p, dir); err != nil {
return err
}
defer docker.Remove(ctx, imgUUID)
if !o.keepCache {
defer docker.Remove(ctx, imgUUID)
}
} else {
// for raw images, we just tag the image with the uuid
if err := docker.Tag(ctx, img, imgUUID); err != nil {
return err
}
defer docker.Remove(ctx, imgUUID)
if !o.keepCache {
defer docker.Remove(ctx, imgUUID)
}
}
logrus.Infof("creating vm image")