Skip to content

Commit bf521fe

Browse files
ndeloofglours
authored andcommitted
implement remove-orphans on run
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 11e9621 commit bf521fe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cmd/compose/run.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type runOptions struct {
6363
name string
6464
noDeps bool
6565
ignoreOrphans bool
66+
removeOrphans bool
6667
quietPull bool
6768
}
6869

@@ -189,7 +190,7 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
189190
flags.BoolVarP(&options.servicePorts, "service-ports", "P", false, "Run command with all service's ports enabled and mapped to the host")
190191
flags.BoolVar(&options.quietPull, "quiet-pull", false, "Pull without printing progress information")
191192
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container")
192-
flags.BoolVar(&createOpts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
193+
flags.BoolVar(&options.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
193194

194195
cmd.Flags().BoolVarP(&options.interactive, "interactive", "i", true, "Keep STDIN open even if not attached")
195196
cmd.Flags().BoolVarP(&options.tty, "tty", "t", true, "Allocate a pseudo-TTY")
@@ -314,6 +315,7 @@ func startDependencies(ctx context.Context, backend api.Service, project types.P
314315
err := backend.Create(ctx, &project, api.CreateOptions{
315316
Build: buildOpts,
316317
IgnoreOrphans: options.ignoreOrphans,
318+
RemoveOrphans: options.removeOrphans,
317319
QuietPull: options.quietPull,
318320
})
319321
if err != nil {

0 commit comments

Comments
 (0)