Skip to content

Commit cc912c6

Browse files
committed
introduce --remove-orphans in compose create command
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent cc7e69c commit cc912c6

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

cmd/compose/create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func createCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
7878
flags.StringVar(&opts.Pull, "pull", "missing", `Pull image before running ("always"|"missing"|"never")`)
7979
flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
8080
flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
81+
flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
8182
return cmd
8283
}
8384

docs/reference/compose_create.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Creates containers for a service.
1212
| `--no-build` | | | Don't build an image, even if it's missing. |
1313
| `--no-recreate` | | | If containers already exist, don't recreate them. Incompatible with --force-recreate. |
1414
| `--pull` | `string` | `missing` | Pull image before running ("always"\|"missing"\|"never") |
15+
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
1516

1617

1718
<!---MARKER_GEN_END-->

docs/reference/docker_compose_create.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ options:
5757
experimentalcli: false
5858
kubernetes: false
5959
swarm: false
60+
- option: remove-orphans
61+
value_type: bool
62+
default_value: "false"
63+
description: Remove containers for services not defined in the Compose file.
64+
deprecated: false
65+
hidden: false
66+
experimental: false
67+
experimentalcli: false
68+
kubernetes: false
69+
swarm: false
6070
deprecated: false
6171
experimental: false
6272
experimentalcli: false

0 commit comments

Comments
 (0)