Skip to content

Commit 0bd132b

Browse files
idsulikglours
authored andcommitted
fix(run): Ensure images exist only for the target service in run command
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com> (cherry picked from commit 557e0b6) Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
1 parent ee86f55 commit 0bd132b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

pkg/compose/run.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,15 @@ func (s *composeService) prepareRun(ctx context.Context, project *types.Project,
9797
Add(api.SlugLabel, slug).
9898
Add(api.OneoffLabel, "True")
9999

100-
if err := s.ensureImagesExists(ctx, project, opts.Build, opts.QuietPull); err != nil { // all dependencies already checked, but might miss service img
100+
// Only ensure image exists for the target service, dependencies were already handled by startDependencies
101+
var buildOpts *api.BuildOptions
102+
if opts.Build != nil {
103+
// Create a copy of build options and restrict to only the target service
104+
buildOptsCopy := *opts.Build
105+
buildOptsCopy.Services = []string{opts.Service}
106+
buildOpts = &buildOptsCopy
107+
}
108+
if err := s.ensureImagesExists(ctx, project, buildOpts, opts.QuietPull); err != nil { // all dependencies already checked, but might miss service img
101109
return "", err
102110
}
103111

0 commit comments

Comments
 (0)