@@ -53,6 +53,7 @@ type runOptions struct {
53
53
servicePorts bool
54
54
name string
55
55
noDeps bool
56
+ ignoreOrphans bool
56
57
quietPull bool
57
58
}
58
59
@@ -134,6 +135,8 @@ func runCommand(p *projectOptions, backend api.Service) *cobra.Command {
134
135
if err != nil {
135
136
return err
136
137
}
138
+ ignore := project .Environment ["COMPOSE_IGNORE_ORPHANS" ]
139
+ opts .ignoreOrphans = strings .ToLower (ignore ) == "true"
137
140
return runRun (ctx , backend , project , opts )
138
141
}),
139
142
ValidArgsFunction : serviceCompletion (p ),
@@ -182,7 +185,7 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op
182
185
}
183
186
184
187
err = progress .Run (ctx , func (ctx context.Context ) error {
185
- return startDependencies (ctx , backend , * project , opts .Service )
188
+ return startDependencies (ctx , backend , * project , opts .Service , opts . ignoreOrphans )
186
189
})
187
190
if err != nil {
188
191
return err
@@ -229,7 +232,7 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op
229
232
return err
230
233
}
231
234
232
- func startDependencies (ctx context.Context , backend api.Service , project types.Project , requestedServiceName string ) error {
235
+ func startDependencies (ctx context.Context , backend api.Service , project types.Project , requestedServiceName string , ignoreOrphans bool ) error {
233
236
dependencies := types.Services {}
234
237
var requestedService types.ServiceConfig
235
238
for _ , service := range project .Services {
@@ -242,7 +245,9 @@ func startDependencies(ctx context.Context, backend api.Service, project types.P
242
245
243
246
project .Services = dependencies
244
247
project .DisabledServices = append (project .DisabledServices , requestedService )
245
- if err := backend .Create (ctx , & project , api.CreateOptions {}); err != nil {
248
+ if err := backend .Create (ctx , & project , api.CreateOptions {
249
+ IgnoreOrphans : ignoreOrphans ,
250
+ }); err != nil {
246
251
return err
247
252
}
248
253
return backend .Start (ctx , project .Name , api.StartOptions {})
0 commit comments