Skip to content

Commit 49fb4ca

Browse files
committed
down: fix COMPOSE_REMOVE_ORPHANS env name and add test
Fixes docker#9562. Signed-off-by: Nick Sieger <[email protected]>
1 parent de0f233 commit 49fb4ca

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

cmd/compose/down.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
6363
ValidArgsFunction: noCompletion(),
6464
}
6565
flags := downCmd.Flags()
66-
removeOrphans := utils.StringToBool(os.Getenv("COMPOSE_REMOVE_ORPHANS "))
66+
removeOrphans := utils.StringToBool(os.Getenv("COMPOSE_REMOVE_ORPHANS"))
6767
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file.")
6868
flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds")
6969
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.")

pkg/e2e/compose_run_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ func TestLocalComposeRun(t *testing.T) {
116116
})
117117

118118
t.Run("down", func(t *testing.T) {
119-
c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/compose.yaml", "down")
120-
c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/orphan.yaml", "down")
119+
cmd := c.NewDockerCmd("compose", "-f", "./fixtures/run-test/compose.yaml", "down")
120+
icmd.RunCmd(cmd, func(c *icmd.Cmd) {
121+
c.Env = append(c.Env, "COMPOSE_REMOVE_ORPHANS=True")
122+
})
121123
res := c.RunDockerCmd(t, "ps", "--all")
122124
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test"), res.Stdout())
123125
})

0 commit comments

Comments
 (0)