Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 99d5991

Browse files
authored
Merge pull request #2006 from docker/revert-1997-image_digest
Revert "introduce ImageDigestLabel to track image built for service"
2 parents fff0ed2 + 15f07f2 commit 99d5991

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pkg/api/labels.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ const (
4747
OneoffLabel = "com.docker.compose.oneoff"
4848
// SlugLabel stores unique slug used for one-off container identity
4949
SlugLabel = "com.docker.compose.slug"
50-
// ImageDigestLabel stores digest of the container image used to run service
51-
ImageDigestLabel = "com.docker.compose.image"
5250
// VersionLabel stores the compose tool version used to run application
5351
VersionLabel = "com.docker.compose.version"
5452
)

pkg/compose/build.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
111111
if quietPull {
112112
mode = xprogress.PrinterModeQuiet
113113
}
114-
opts, err := s.getBuildOptions(project, images)
114+
opts, imagesToBuild, err := s.getBuildOptions(project, images)
115115
if err != nil {
116116
return err
117117
}
@@ -120,7 +120,7 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
120120
return err
121121
}
122122

123-
if len(builtImages) > 0 {
123+
if len(imagesToBuild) > 0 {
124124
utils.DisplayScanSuggestMsg()
125125
}
126126
for name, digest := range builtImages {
@@ -130,17 +130,18 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
130130
for i, service := range project.Services {
131131
digest, ok := images[getImageName(service, project.Name)]
132132
if ok {
133-
project.Services[i].Labels[api.ImageDigestLabel] = digest
133+
project.Services[i].Image = digest
134134
}
135135
}
136136
return nil
137137
}
138138

139-
func (s *composeService) getBuildOptions(project *types.Project, images map[string]string) (map[string]build.Options, error) {
139+
func (s *composeService) getBuildOptions(project *types.Project, images map[string]string) (map[string]build.Options, []string, error) {
140140
opts := map[string]build.Options{}
141+
imagesToBuild := []string{}
141142
for _, service := range project.Services {
142143
if service.Image == "" && service.Build == nil {
143-
return nil, fmt.Errorf("invalid service %q. Must specify either image or build", service.Name)
144+
return nil, nil, fmt.Errorf("invalid service %q. Must specify either image or build", service.Name)
144145
}
145146
imageName := getImageName(service, project.Name)
146147
_, localImagePresent := images[imageName]
@@ -149,15 +150,16 @@ func (s *composeService) getBuildOptions(project *types.Project, images map[stri
149150
if localImagePresent && service.PullPolicy != types.PullPolicyBuild {
150151
continue
151152
}
153+
imagesToBuild = append(imagesToBuild, imageName)
152154
opt, err := s.toBuildOptions(project, service, imageName)
153155
if err != nil {
154-
return nil, err
156+
return nil, nil, err
155157
}
156158
opts[imageName] = opt
157159
continue
158160
}
159161
}
160-
return opts, nil
162+
return opts, imagesToBuild, nil
161163

162164
}
163165

0 commit comments

Comments
 (0)