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

Function resolveImageVolumes

pkg/compose/build.go:169–190  ·  view source on GitHub ↗
(service *types.ServiceConfig, images map[string]api.ImageSummary, projectName string)

Source from the content-addressed store, hash-verified

167}
168
169func resolveImageVolumes(service *types.ServiceConfig, images map[string]api.ImageSummary, projectName string) {
170 for i, vol := range service.Volumes {
171 if vol.Type == types.VolumeTypeImage {
172 imgName := vol.Source
173 if _, ok := images[vol.Source]; !ok {
174 // check if source is another service in the project
175 imgName = api.GetImageNameOrDefault(types.ServiceConfig{Name: vol.Source}, projectName)
176 // If we still can't find it, it might be an external image that wasn't pulled yet or doesn't exist
177 if _, ok := images[imgName]; !ok {
178 continue
179 }
180 }
181 if img, ok := images[imgName]; ok {
182 // Use Image ID directly as source.
183 // Using name@digest format (via reference.WithDigest) fails for local-only images
184 // that don't have RepoDigests (e.g. built locally in CI).
185 // Image ID (sha256:...) is always valid and ensures ServiceHash changes on rebuild.
186 service.Volumes[i].Source = img.ID
187 }
188 }
189 }
190}
191
192func (s *composeService) getLocalImagesDigests(ctx context.Context, project *types.Project) (map[string]api.ImageSummary, error) {
193 imageNames := utils.Set[string]{}

Callers 1

ensureImagesExistsMethod · 0.85

Calls 1

GetImageNameOrDefaultFunction · 0.92

Tested by

no test coverage detected