Pārlūkot izejas kodu

introduce --no-deps on restart

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 2 gadi atpakaļ
vecāks
revīzija
0612b34c68

+ 9 - 0
cmd/compose/restart.go

@@ -28,6 +28,7 @@ import (
 type restartOptions struct {
 	*ProjectOptions
 	timeout int
+	noDeps  bool
 }
 
 func restartCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
@@ -44,6 +45,7 @@ func restartCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
 	}
 	flags := restartCmd.Flags()
 	flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds")
+	flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't restart dependent services.")
 
 	return restartCmd
 }
@@ -54,6 +56,13 @@ func runRestart(ctx context.Context, backend api.Service, opts restartOptions, s
 		return err
 	}
 
+	if opts.noDeps {
+		err := withSelectedServicesOnly(project, services)
+		if err != nil {
+			return err
+		}
+	}
+
 	timeout := time.Duration(opts.timeout) * time.Second
 	return backend.Restart(ctx, name, api.RestartOptions{
 		Timeout:  &timeout,

+ 1 - 0
docs/reference/compose_restart.md

@@ -7,6 +7,7 @@ Restart service containers
 
 | Name              | Type  | Default | Description                           |
 |:------------------|:------|:--------|:--------------------------------------|
+| `--no-deps`       |       |         | Don't restart dependent services.     |
 | `-t`, `--timeout` | `int` | `10`    | Specify a shutdown timeout in seconds |
 
 

+ 10 - 0
docs/reference/docker_compose_restart.yaml

@@ -15,6 +15,16 @@ usage: docker compose restart [OPTIONS] [SERVICE...]
 pname: docker compose
 plink: docker_compose.yaml
 options:
+    - option: no-deps
+      value_type: bool
+      default_value: "false"
+      description: Don't restart dependent services.
+      deprecated: false
+      hidden: false
+      experimental: false
+      experimentalcli: false
+      kubernetes: false
+      swarm: false
     - option: timeout
       shorthand: t
       value_type: int