diff --git a/pkg/compose/start.go b/pkg/compose/start.go index e4ce16fd47..b1814d4abd 100644 --- a/pkg/compose/start.go +++ b/pkg/compose/start.go @@ -123,6 +123,12 @@ func (s *composeService) start(ctx context.Context, projectName string, options return err } + if options.Wait && options.WaitTimeout > 0 { + withTimeout, cancel := context.WithTimeout(ctx, options.WaitTimeout) + ctx = withTimeout + defer cancel() + } + err = InDependencyOrder(ctx, project, func(c context.Context, name string) error { service, err := project.GetService(name) if err != nil { @@ -131,6 +137,7 @@ func (s *composeService) start(ctx context.Context, projectName string, options return s.startService(ctx, project, service, containers, listener, options.WaitTimeout) }) + if err != nil { return err } @@ -143,11 +150,6 @@ func (s *composeService) start(ctx context.Context, projectName string, options Required: true, } } - if options.WaitTimeout > 0 { - withTimeout, cancel := context.WithTimeout(ctx, options.WaitTimeout) - ctx = withTimeout - defer cancel() - } err = s.waitDependencies(ctx, project, project.Name, depends, containers, 0) if err != nil {