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

Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
This commit is contained in:
Suleiman Dibirov
2025-10-28 16:08:44 +02:00
committed by Guillaume Lours
parent a8933c91e7
commit 557e0b6ec7

View File

@@ -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
}