From 45542827ddbf2f4fd8215fc7098c7f67eaff5682 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Wed, 24 Jan 2024 15:07:47 -0700 Subject: [PATCH] Remove built images when renaming a container Renaming a container causes its images to be abandoned in the previous name. This causes those images to be removed after a successful rename. New images can be rebuilt during the rename using the `--build` argument. Signed-off-by: Jonathon Anderson --- internal/pkg/api/container/container.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/pkg/api/container/container.go b/internal/pkg/api/container/container.go index f4a4eb5b..f81c1b20 100644 --- a/internal/pkg/api/container/container.go +++ b/internal/pkg/api/container/container.go @@ -413,6 +413,11 @@ func ContainerRename(crp *wwapiv1.ContainerRenameParameter) (err error) { return err } + err = container.DeleteImage(crp.ContainerName) + if err != nil { + wwlog.Warn("Could not remove image files for %s: %w", crp.ContainerName, err) + } + if crp.Build { err = container.Build(crp.TargetName, true) if err != nil {