Skip to content

Commit bd8e574

Browse files
committed
Add remove-orphans functionality to run, because it recommends that in error messages
Signed-off-by: Matt Armand <[email protected]>
1 parent 4ad8746 commit bd8e574

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

cmd/compose/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func runCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *co
162162
flags.BoolVar(&opts.servicePorts, "service-ports", false, "Run command with the service's ports enabled and mapped to the host.")
163163
flags.BoolVar(&opts.quietPull, "quiet-pull", false, "Pull without printing progress information.")
164164
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container.")
165+
flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
165166

166167
cmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached.")
167168
cmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY.")

docs/reference/compose_run.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Run a one-off command on a service.
2424
| `-u`, `--user` | `string` | | Run as specified username or uid |
2525
| `-v`, `--volume` | `stringArray` | | Bind mount a volume. |
2626
| `-w`, `--workdir` | `string` | | Working directory inside the container |
27+
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
2728

2829

2930
<!---MARKER_GEN_END-->

docs/reference/docker_compose_run.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,18 @@ options:
246246
experimentalcli: false
247247
kubernetes: false
248248
swarm: false
249+
- option: remove-orphans
250+
value_type: bool
251+
default_value: "false"
252+
description: Remove containers for services not defined in the Compose file.
253+
deprecated: false
254+
hidden: false
255+
experimental: false
256+
experimentalcli: false
257+
kubernetes: false
258+
swarm: false
249259
deprecated: false
250260
experimental: false
251261
experimentalcli: false
252262
kubernetes: false
253263
swarm: false
254-

0 commit comments

Comments
 (0)