Skip to content

Commit aa864fd

Browse files
committed
COMPOSE_REMOVE_ORPHANS can be set to always apply --remove-orphans
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent f7a6c3b commit aa864fd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/compose/down.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package compose
1919
import (
2020
"context"
2121
"fmt"
22+
"os"
23+
"strings"
2224
"time"
2325

2426
"github.com/compose-spec/compose-go/types"
@@ -60,7 +62,8 @@ func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
6062
ValidArgsFunction: noCompletion(),
6163
}
6264
flags := downCmd.Flags()
63-
flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
65+
removeOrphans := strings.ToLower(os.Getenv("COMPOSE_REMOVE_ORPHANS ")) == "true"
66+
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file.")
6467
flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds")
6568
flags.BoolVarP(&opts.volumes, "volumes", "v", false, " Remove named volumes declared in the `volumes` section of the Compose file and anonymous volumes attached to containers.")
6669
flags.StringVar(&opts.images, "rmi", "", `Remove images used by services. "local" remove only images that don't have a custom tag ("local"|"all")`)

0 commit comments

Comments
 (0)