@@ -69,15 +69,13 @@ func runRun(ctx context.Context, opts runOptions) error {
6969 return err
7070 }
7171
72- originalServices := project .Services
7372 _ , err = progress .Run (ctx , func (ctx context.Context ) (string , error ) {
74- return "" , startDependencies (ctx , c , project , opts .Service )
73+ return "" , startDependencies (ctx , c , * project , opts .Service )
7574 })
7675 if err != nil {
7776 return err
7877 }
7978
80- project .Services = originalServices
8179 // start container and attach to container streams
8280 runOpts := compose.RunOptions {
8381 Service : opts .Service ,
@@ -90,21 +88,24 @@ func runRun(ctx context.Context, opts runOptions) error {
9088 return c .ComposeService ().RunOneOffContainer (ctx , project , runOpts )
9189}
9290
93- func startDependencies (ctx context.Context , c * client.Client , project * types.Project , requestedService string ) error {
94- originalServices := project .Services
91+ func startDependencies (ctx context.Context , c * client.Client , project types.Project , requestedServiceName string ) error {
9592 dependencies := types.Services {}
96- for _ , service := range originalServices {
97- if service .Name != requestedService {
93+ var requestedService types.ServiceConfig
94+ for _ , service := range project .Services {
95+ if service .Name != requestedServiceName {
9896 dependencies = append (dependencies , service )
97+ } else {
98+ requestedService = service
9999 }
100100 }
101+
101102 project .Services = dependencies
102- if err := c .ComposeService ().Create (ctx , project , compose.CreateOptions {}); err != nil {
103+ project .DisabledServices = append (project .DisabledServices , requestedService )
104+ if err := c .ComposeService ().Create (ctx , & project , compose.CreateOptions {}); err != nil {
103105 return err
104106 }
105- if err := c .ComposeService ().Start (ctx , project , compose.StartOptions {}); err != nil {
107+ if err := c .ComposeService ().Start (ctx , & project , compose.StartOptions {}); err != nil {
106108 return err
107109 }
108110 return nil
109-
110111}
0 commit comments