diff --git a/cmd/compose/restart.go b/cmd/compose/restart.go index 5ff5946ec..a64d8fe66 100644 --- a/cmd/compose/restart.go +++ b/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, diff --git a/docs/reference/compose_restart.md b/docs/reference/compose_restart.md index b561b5447..ff201c2f7 100644 --- a/docs/reference/compose_restart.md +++ b/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 | diff --git a/docs/reference/docker_compose_restart.yaml b/docs/reference/docker_compose_restart.yaml index ea6c2628b..91ba742e8 100644 --- a/docs/reference/docker_compose_restart.yaml +++ b/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