From 4b20d77a86898dee594cd5cab0298d0f91c34b92 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Wed, 3 Feb 2021 15:50:49 +0100 Subject: [PATCH] =?UTF-8?q?Expose=20`=E2=80=94remove-orphans`=20in=20compo?= =?UTF-8?q?se=20down=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guillaume Tardif --- cli/cmd/compose/down.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/cmd/compose/down.go b/cli/cmd/compose/down.go index ef48e71a8..ca92e96f5 100644 --- a/cli/cmd/compose/down.go +++ b/cli/cmd/compose/down.go @@ -31,6 +31,7 @@ import ( type downOptions struct { *projectOptions + removeOrphans bool } func downCommand(p *projectOptions) *cobra.Command { @@ -44,6 +45,9 @@ func downCommand(p *projectOptions) *cobra.Command { return runDown(cmd.Context(), opts) }, } + flags := downCmd.Flags() + flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.") + return downCmd } @@ -66,7 +70,7 @@ func runDown(ctx context.Context, opts downOptions) error { } return name, c.ComposeService().Down(ctx, name, compose.DownOptions{ - RemoveOrphans: false, + RemoveOrphans: opts.removeOrphans, Project: project, }) })