From a9e070206ef881b463850fd2cb38f7b84e152280 Mon Sep 17 00:00:00 2001 From: Guillaume Lours <705411+glours@users.noreply.github.com> Date: Wed, 9 Nov 2022 19:51:11 +0100 Subject: [PATCH] check if a missing image won't be build via a service declared in depends_on section Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> --- pkg/compose/pull.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/compose/pull.go b/pkg/compose/pull.go index 88cfefbf..d3b794c6 100644 --- a/pkg/compose/pull.go +++ b/pkg/compose/pull.go @@ -271,7 +271,7 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types. eg.Go(func() error { id, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, quietPull) pulledImages[i] = id - if err != nil && service.Build != nil { + if err != nil && isServiceImageToBuild(service, project.Services) { // image can be built, so we can ignore pull failure return nil } @@ -291,6 +291,19 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types. }) } +func isServiceImageToBuild(service types.ServiceConfig, services []types.ServiceConfig) bool { + if service.Build != nil { + return true + } + + for _, depService := range services { + if depService.Image == service.Image && depService.Build != nil { + return true + } + } + return false +} + func toPullProgressEvent(parent string, jm jsonmessage.JSONMessage, w progress.Writer) { if jm.ID == "" || jm.Progress == nil { return