-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete image for current task only. #650
Conversation
Team conclusion: just delete the task's Docker image (instead of listing all and deleting just that one) |
throw; | ||
} | ||
} | ||
await dockerClient.Images.DeleteImageAsync(imageName, new ImageDeleteParameters { Force = true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work as expected? I thought it needed the image.ID, which I didn't think was the same as imageName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it works, the trick was to get the container object and then use that to get the image name. The delete api will accept either the image sha or an image name with tag, however if you try executionOptions.ImageName it won't work sometimes for images with a "latest" tag. When you pull it dcoker does the substitution from ubuntu:latest to ubuntu:22.04 so you can't delete by calling delete on ubuntu:latest. (I would think it should keep both tags, but it doesn't seem to via the api at least)
} | ||
catch (Exception e) | ||
{ | ||
logger.LogError(e, "Exception in DeleteAllImagesAsync"); | ||
throw; | ||
logger.LogWarning(@"Failed to delete image {ImageName}. Error: {ErrorMessage}", imageName, e.Message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you checked the logs to ensure this is not written? How did you test to see if the image was actually deleted? (or checked to see if the Informational log above was written)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I downloaded the tes runner logs and confirmed it printed " Deleted Docker image ". Since we're only deleting the task image, actually I should probably add the throw back in.
Fixes: #688