Ver Fonte

Merge pull request #10166 from matthewarmand/run-remove-orphans

Add remove-orphans functionality to run
Laura Brehm há 2 anos atrás
pai
commit
7212aaff2e

+ 1 - 0
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(&createOpts.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.")

+ 1 - 0
docs/reference/compose_run.md

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

+ 10 - 0
docs/reference/docker_compose_run.yaml

@@ -172,6 +172,16 @@ 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
     - option: rm
       value_type: bool
       default_value: "false"