diff --git a/cmd/compose/run.go b/cmd/compose/run.go index 344ee50c7..9ae5d7d88 100644 --- a/cmd/compose/run.go +++ b/cmd/compose/run.go @@ -162,6 +162,7 @@ func runCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *co flags.BoolVar(&opts.servicePorts, "service-ports", false, "Run command with the service's ports enabled and mapped to the host.") flags.BoolVar(&opts.quietPull, "quiet-pull", false, "Pull without printing progress information.") flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container.") + flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.") cmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached.") cmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY.") diff --git a/docs/reference/compose_run.md b/docs/reference/compose_run.md index a870a9067..3c924ea29 100644 --- a/docs/reference/compose_run.md +++ b/docs/reference/compose_run.md @@ -24,6 +24,7 @@ Run a one-off command on a service. | `-u`, `--user` | `string` | | Run as specified username or uid | | `-v`, `--volume` | `stringArray` | | Bind mount a volume. | | `-w`, `--workdir` | `string` | | Working directory inside the container | +| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. | diff --git a/docs/reference/docker_compose_run.yaml b/docs/reference/docker_compose_run.yaml index 9d5715f4e..8ac5f1c35 100644 --- a/docs/reference/docker_compose_run.yaml +++ b/docs/reference/docker_compose_run.yaml @@ -246,9 +246,18 @@ options: experimentalcli: false kubernetes: false swarm: false + - option: remove-orphans + value_type: bool + default_value: "false" + description: Remove containers for services not defined in the Compose file. + deprecated: false + hidden: false + experimental: false + experimentalcli: false + kubernetes: false + swarm: false deprecated: false experimental: false experimentalcli: false kubernetes: false swarm: false -