Skip to content

Commit 6be5f30

Browse files
committed
move watch from alpha to main command
Signed-off-by: Guillaume Lours <[email protected]>
1 parent 421a6b0 commit 6be5f30

File tree

9 files changed

+106
-38
lines changed

9 files changed

+106
-38
lines changed

cmd/compose/compose.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
477477
copyCommand(&opts, dockerCli, backend),
478478
waitCommand(&opts, dockerCli, backend),
479479
scaleCommand(&opts, dockerCli, backend),
480+
watchCommand(&opts, dockerCli, backend),
480481
alphaCommand(&opts, dockerCli, backend),
481482
)
482483

cmd/compose/watch.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ package compose
1919
import (
2020
"context"
2121
"fmt"
22-
"os"
2322

2423
"github.com/docker/cli/cli/command"
2524
"github.com/docker/compose/v2/internal/locker"
26-
2725
"github.com/docker/compose/v2/pkg/api"
26+
"github.com/sirupsen/logrus"
2827
"github.com/spf13/cobra"
2928
)
3029

@@ -43,11 +42,14 @@ func watchCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
4342
}
4443
cmd := &cobra.Command{
4544
Use: "watch [SERVICE...]",
46-
Short: "EXPERIMENTAL - Watch build context for service and rebuild/refresh containers when files are updated",
45+
Short: "Watch build context for service and rebuild/refresh containers when files are updated",
4746
PreRunE: Adapt(func(ctx context.Context, args []string) error {
4847
return nil
4948
}),
50-
RunE: Adapt(func(ctx context.Context, args []string) error {
49+
RunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
50+
if cmd.Parent().Name() == "alpha" {
51+
logrus.Warn("watch command is now available as a top level command")
52+
}
5153
return runWatch(ctx, dockerCli, backend, watchOpts, buildOpts, args)
5254
}),
5355
ValidArgsFunction: completeServiceNames(dockerCli, p),
@@ -59,7 +61,6 @@ func watchCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
5961
}
6062

6163
func runWatch(ctx context.Context, dockerCli command.Cli, backend api.Service, watchOpts watchOptions, buildOpts buildOptions, services []string) error {
62-
fmt.Fprintln(os.Stderr, "watch command is EXPERIMENTAL")
6364
project, err := watchOpts.ToProject(dockerCli, nil)
6465
if err != nil {
6566
return err

docs/reference/compose.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,36 @@ Define and run multi-container applications with Docker.
55

66
### Subcommands
77

8-
| Name | Description |
9-
|:--------------------------------|:------------------------------------------------------------------------|
10-
| [`build`](compose_build.md) | Build or rebuild services |
11-
| [`config`](compose_config.md) | Parse, resolve and render compose file in canonical format |
12-
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
13-
| [`create`](compose_create.md) | Creates containers for a service. |
14-
| [`down`](compose_down.md) | Stop and remove containers, networks |
15-
| [`events`](compose_events.md) | Receive real time events from containers. |
16-
| [`exec`](compose_exec.md) | Execute a command in a running container. |
17-
| [`images`](compose_images.md) | List images used by the created containers |
18-
| [`kill`](compose_kill.md) | Force stop service containers. |
19-
| [`logs`](compose_logs.md) | View output from containers |
20-
| [`ls`](compose_ls.md) | List running compose projects |
21-
| [`pause`](compose_pause.md) | Pause services |
22-
| [`port`](compose_port.md) | Print the public port for a port binding. |
23-
| [`ps`](compose_ps.md) | List containers |
24-
| [`pull`](compose_pull.md) | Pull service images |
25-
| [`push`](compose_push.md) | Push service images |
26-
| [`restart`](compose_restart.md) | Restart service containers |
27-
| [`rm`](compose_rm.md) | Removes stopped service containers |
28-
| [`run`](compose_run.md) | Run a one-off command on a service. |
29-
| [`scale`](compose_scale.md) | Scale services |
30-
| [`start`](compose_start.md) | Start services |
31-
| [`stop`](compose_stop.md) | Stop services |
32-
| [`top`](compose_top.md) | Display the running processes |
33-
| [`unpause`](compose_unpause.md) | Unpause services |
34-
| [`up`](compose_up.md) | Create and start containers |
35-
| [`version`](compose_version.md) | Show the Docker Compose version information |
36-
| [`wait`](compose_wait.md) | Block until the first service container stops |
8+
| Name | Description |
9+
|:--------------------------------|:--------------------------------------------------------------------------------------|
10+
| [`build`](compose_build.md) | Build or rebuild services |
11+
| [`config`](compose_config.md) | Parse, resolve and render compose file in canonical format |
12+
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
13+
| [`create`](compose_create.md) | Creates containers for a service. |
14+
| [`down`](compose_down.md) | Stop and remove containers, networks |
15+
| [`events`](compose_events.md) | Receive real time events from containers. |
16+
| [`exec`](compose_exec.md) | Execute a command in a running container. |
17+
| [`images`](compose_images.md) | List images used by the created containers |
18+
| [`kill`](compose_kill.md) | Force stop service containers. |
19+
| [`logs`](compose_logs.md) | View output from containers |
20+
| [`ls`](compose_ls.md) | List running compose projects |
21+
| [`pause`](compose_pause.md) | Pause services |
22+
| [`port`](compose_port.md) | Print the public port for a port binding. |
23+
| [`ps`](compose_ps.md) | List containers |
24+
| [`pull`](compose_pull.md) | Pull service images |
25+
| [`push`](compose_push.md) | Push service images |
26+
| [`restart`](compose_restart.md) | Restart service containers |
27+
| [`rm`](compose_rm.md) | Removes stopped service containers |
28+
| [`run`](compose_run.md) | Run a one-off command on a service. |
29+
| [`scale`](compose_scale.md) | Scale services |
30+
| [`start`](compose_start.md) | Start services |
31+
| [`stop`](compose_stop.md) | Stop services |
32+
| [`top`](compose_top.md) | Display the running processes |
33+
| [`unpause`](compose_unpause.md) | Unpause services |
34+
| [`up`](compose_up.md) | Create and start containers |
35+
| [`version`](compose_version.md) | Show the Docker Compose version information |
36+
| [`wait`](compose_wait.md) | Block until the first service container stops |
37+
| [`watch`](compose_watch.md) | Watch build context for service and rebuild/refresh containers when files are updated |
3738

3839

3940
### Options

docs/reference/compose_alpha_watch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# docker compose alpha watch
22

33
<!---MARKER_GEN_START-->
4-
EXPERIMENTAL - Watch build context for service and rebuild/refresh containers when files are updated
4+
Watch build context for service and rebuild/refresh containers when files are updated
55

66
### Options
77

docs/reference/compose_watch.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# docker compose watch
2+
3+
<!---MARKER_GEN_START-->
4+
Watch build context for service and rebuild/refresh containers when files are updated
5+
6+
### Options
7+
8+
| Name | Type | Default | Description |
9+
|:------------|:-----|:--------|:----------------------------------------------|
10+
| `--dry-run` | | | Execute command in dry run mode |
11+
| `--no-up` | | | Do not build & start services before watching |
12+
| `--quiet` | | | hide build output |
13+
14+
15+
<!---MARKER_GEN_END-->
16+

docs/reference/docker_compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ cname:
173173
- docker compose up
174174
- docker compose version
175175
- docker compose wait
176+
- docker compose watch
176177
clink:
177178
- docker_compose_build.yaml
178179
- docker_compose_config.yaml
@@ -201,6 +202,7 @@ clink:
201202
- docker_compose_up.yaml
202203
- docker_compose_version.yaml
203204
- docker_compose_wait.yaml
205+
- docker_compose_watch.yaml
204206
options:
205207
- option: ansi
206208
value_type: string

docs/reference/docker_compose_alpha_watch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
command: docker compose alpha watch
22
short: |
3-
EXPERIMENTAL - Watch build context for service and rebuild/refresh containers when files are updated
3+
Watch build context for service and rebuild/refresh containers when files are updated
44
long: |
5-
EXPERIMENTAL - Watch build context for service and rebuild/refresh containers when files are updated
5+
Watch build context for service and rebuild/refresh containers when files are updated
66
usage: docker compose alpha watch [SERVICE...]
77
pname: docker compose alpha
88
plink: docker_compose_alpha.yaml
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
command: docker compose watch
2+
short: |
3+
Watch build context for service and rebuild/refresh containers when files are updated
4+
long: |
5+
Watch build context for service and rebuild/refresh containers when files are updated
6+
usage: docker compose watch [SERVICE...]
7+
pname: docker compose
8+
plink: docker_compose.yaml
9+
options:
10+
- option: no-up
11+
value_type: bool
12+
default_value: "false"
13+
description: Do not build & start services before watching
14+
deprecated: false
15+
hidden: false
16+
experimental: false
17+
experimentalcli: false
18+
kubernetes: false
19+
swarm: false
20+
- option: quiet
21+
value_type: bool
22+
default_value: "false"
23+
description: hide build output
24+
deprecated: false
25+
hidden: false
26+
experimental: false
27+
experimentalcli: false
28+
kubernetes: false
29+
swarm: false
30+
inherited_options:
31+
- option: dry-run
32+
value_type: bool
33+
default_value: "false"
34+
description: Execute command in dry run mode
35+
deprecated: false
36+
hidden: false
37+
experimental: false
38+
experimentalcli: false
39+
kubernetes: false
40+
swarm: false
41+
deprecated: false
42+
hidden: false
43+
experimental: false
44+
experimentalcli: false
45+
kubernetes: false
46+
swarm: false
47+

pkg/e2e/watch_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func doTest(t *testing.T, svcName string, tarSync bool) {
8989
cleanup()
9090
t.Cleanup(cleanup)
9191

92-
cmd := cli.NewDockerComposeCmd(t, "--verbose", "alpha", "watch", svcName)
92+
cmd := cli.NewDockerComposeCmd(t, "--verbose", "watch", svcName)
9393
// stream output since watch runs in the background
9494
cmd.Stdout = os.Stdout
9595
cmd.Stderr = os.Stderr

0 commit comments

Comments
 (0)