Skip to content

Commit 7212aaf

Browse files
authored
Merge pull request docker#10166 from matthewarmand/run-remove-orphans
Add remove-orphans functionality to run
2 parents 69a0962 + dadad01 commit 7212aaf

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
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(&createOpts.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
@@ -18,6 +18,7 @@ Run a one-off command on a service.
1818
| `--no-deps` | | | Don't start linked services. |
1919
| `-p`, `--publish` | `stringArray` | | Publish a container's port(s) to the host. |
2020
| `--quiet-pull` | | | Pull without printing progress information. |
21+
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
2122
| `--rm` | | | Automatically remove the container when it exits |
2223
| `--service-ports` | | | Run command with the service's ports enabled and mapped to the host. |
2324
| `--use-aliases` | | | Use the service's network useAliases in the network(s) the container connects to. |

docs/reference/docker_compose_run.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ options:
172172
experimentalcli: false
173173
kubernetes: false
174174
swarm: false
175+
- option: remove-orphans
176+
value_type: bool
177+
default_value: "false"
178+
description: Remove containers for services not defined in the Compose file.
179+
deprecated: false
180+
hidden: false
181+
experimental: false
182+
experimentalcli: false
183+
kubernetes: false
184+
swarm: false
175185
- option: rm
176186
value_type: bool
177187
default_value: "false"

0 commit comments

Comments
 (0)