Skip to content

Commit 0612b34

Browse files
committed
introduce --no-deps on restart
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 92e0cd4 commit 0612b34

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

cmd/compose/restart.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
type restartOptions struct {
2929
*ProjectOptions
3030
timeout int
31+
noDeps bool
3132
}
3233

3334
func restartCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
@@ -44,6 +45,7 @@ func restartCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
4445
}
4546
flags := restartCmd.Flags()
4647
flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds")
48+
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't restart dependent services.")
4749

4850
return restartCmd
4951
}
@@ -54,6 +56,13 @@ func runRestart(ctx context.Context, backend api.Service, opts restartOptions, s
5456
return err
5557
}
5658

59+
if opts.noDeps {
60+
err := withSelectedServicesOnly(project, services)
61+
if err != nil {
62+
return err
63+
}
64+
}
65+
5766
timeout := time.Duration(opts.timeout) * time.Second
5867
return backend.Restart(ctx, name, api.RestartOptions{
5968
Timeout: &timeout,

docs/reference/compose_restart.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Restart service containers
77

88
| Name | Type | Default | Description |
99
|:------------------|:------|:--------|:--------------------------------------|
10+
| `--no-deps` | | | Don't restart dependent services. |
1011
| `-t`, `--timeout` | `int` | `10` | Specify a shutdown timeout in seconds |
1112

1213

docs/reference/docker_compose_restart.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ usage: docker compose restart [OPTIONS] [SERVICE...]
1515
pname: docker compose
1616
plink: docker_compose.yaml
1717
options:
18+
- option: no-deps
19+
value_type: bool
20+
default_value: "false"
21+
description: Don't restart dependent services.
22+
deprecated: false
23+
hidden: false
24+
experimental: false
25+
experimentalcli: false
26+
kubernetes: false
27+
swarm: false
1828
- option: timeout
1929
shorthand: t
2030
value_type: int

0 commit comments

Comments
 (0)