Răsfoiți Sursa

fix(run): Ensure images exist only for the target service in run command

Signed-off-by: Suleiman Dibirov <[email protected]>
(cherry picked from commit 557e0b6ec7a9fb2275e3845e7e79d80453ec1bde)
Signed-off-by: Guillaume Lours <[email protected]>
Suleiman Dibirov 2 luni în urmă
părinte
comite
0bd132b547
1 a modificat fișierele cu 9 adăugiri și 1 ștergeri
  1. 9 1
      pkg/compose/run.go

+ 9 - 1
pkg/compose/run.go

@@ -97,7 +97,15 @@ func (s *composeService) prepareRun(ctx context.Context, project *types.Project,
 		Add(api.SlugLabel, slug).
 		Add(api.OneoffLabel, "True")
 
-	if err := s.ensureImagesExists(ctx, project, opts.Build, opts.QuietPull); err != nil { // all dependencies already checked, but might miss service img
+	// Only ensure image exists for the target service, dependencies were already handled by startDependencies
+	var buildOpts *api.BuildOptions
+	if opts.Build != nil {
+		// Create a copy of build options and restrict to only the target service
+		buildOptsCopy := *opts.Build
+		buildOptsCopy.Services = []string{opts.Service}
+		buildOpts = &buildOptsCopy
+	}
+	if err := s.ensureImagesExists(ctx, project, buildOpts, opts.QuietPull); err != nil { // all dependencies already checked, but might miss service img
 		return "", err
 	}