MCPcopy
hub / github.com/docker/compose / pruneDanglingImagesOnRebuild

Method pruneDanglingImagesOnRebuild

pkg/compose/watch.go:720–737  ·  view source on GitHub ↗
(ctx context.Context, projectName string, imageNameToIdMap map[string]string)

Source from the content-addressed store, hash-verified

718}
719
720func (s *composeService) pruneDanglingImagesOnRebuild(ctx context.Context, projectName string, imageNameToIdMap map[string]string) {
721 images, err := s.apiClient().ImageList(ctx, client.ImageListOptions{
722 Filters: projectFilter(projectName).Add("dangling", "true"),
723 })
724 if err != nil {
725 logrus.Debugf("Failed to list images: %v", err)
726 return
727 }
728
729 for _, img := range images.Items {
730 if _, ok := imageNameToIdMap[img.ID]; !ok {
731 _, err := s.apiClient().ImageRemove(ctx, img.ID, client.ImageRemoveOptions{})
732 if err != nil {
733 logrus.Debugf("Failed to remove image %s: %v", img.ID, err)
734 }
735 }
736 }
737}
738
739// Walks develop.watch.path and checks which files should be copied inside the container
740// ignores develop.watch.ignore, Dockerfile, compose files, bind mounted paths and .git

Callers 1

rebuildMethod · 0.95

Calls 5

apiClientMethod · 0.95
projectFilterFunction · 0.85
ImageListMethod · 0.45
AddMethod · 0.45
ImageRemoveMethod · 0.45

Tested by

no test coverage detected