@@ -162,23 +162,31 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types.
162
162
info .IndexServerAddress = registry .IndexServer
163
163
}
164
164
165
+ var needPull []types.ServiceConfig
166
+ for _ , service := range project .Services {
167
+ if service .Image == "" {
168
+ continue
169
+ }
170
+ switch service .PullPolicy {
171
+ case "" , types .PullPolicyMissing , types .PullPolicyIfNotPresent :
172
+ if _ , ok := images [service .Image ]; ok {
173
+ continue
174
+ }
175
+ case types .PullPolicyNever , types .PullPolicyBuild :
176
+ continue
177
+ case types .PullPolicyAlways :
178
+ // force pull
179
+ }
180
+ needPull = append (needPull , service )
181
+ }
182
+ if len (needPull ) == 0 {
183
+ return nil
184
+ }
185
+
165
186
return progress .Run (ctx , func (ctx context.Context ) error {
166
187
w := progress .ContextWriter (ctx )
167
188
eg , ctx := errgroup .WithContext (ctx )
168
- for _ , service := range project .Services {
169
- if service .Image == "" {
170
- continue
171
- }
172
- switch service .PullPolicy {
173
- case types .PullPolicyMissing , types .PullPolicyIfNotPresent :
174
- if _ , ok := images [service .Image ]; ok {
175
- continue
176
- }
177
- case types .PullPolicyNever , types .PullPolicyBuild :
178
- continue
179
- case types .PullPolicyAlways :
180
- // force pull
181
- }
189
+ for _ , service := range needPull {
182
190
service := service
183
191
eg .Go (func () error {
184
192
err := s .pullServiceImage (ctx , service , info , s .configFile , w , quietPull )
0 commit comments