From abdbfb8cd24f2c0f145187a05ed55158fd0fd2ec Mon Sep 17 00:00:00 2001 From: Gautham Hullikunte <46633282+batcity@users.noreply.github.com> Date: Tue, 6 Feb 2024 00:32:50 +0530 Subject: [PATCH] Issue-11374: Modified compose up command to respect COMPOSE_REMOVE_ORPHANS environment variable Signed-off-by: Gautham Hullikunte <46633282+batcity@users.noreply.github.com> --- cmd/compose/up.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/compose/up.go b/cmd/compose/up.go index c4919ca80e8..e72a40f6df8 100644 --- a/cmd/compose/up.go +++ b/cmd/compose/up.go @@ -20,6 +20,7 @@ import ( "context" "errors" "fmt" + "os" "strings" "time" @@ -104,7 +105,8 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c flags.BoolVar(&create.Build, "build", false, "Build images before starting containers.") flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's policy.") flags.StringVar(&create.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never")`) - flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.") + removeOrphans := utils.StringToBool(os.Getenv(ComposeRemoveOrphans)) + flags.BoolVar(&create.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file.") flags.StringArrayVar(&create.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.") flags.BoolVar(&up.noColor, "no-color", false, "Produce monochrome output.") flags.BoolVar(&up.noPrefix, "no-log-prefix", false, "Don't print prefix in logs.")