Skip to content

[BUG] docker compose watch <service> ignores depdends_on definitions #11813

@MarcusElevait

Description

@MarcusElevait

Description

When running docker compose watch <service> it ignores every depends_on definition and just starts all services defined in the compose file.

Expectation would be, that it would not start services, that are not defined in the depends_on section.
The interesting thing is, if i run docker compose up --watch servicec it uses the depends_on definition and does not start unnecessary services.

Steps To Reproduce

  1. Create simple compose file like this:
services:
    servicea:
        build: .
        develop:
            watch:
            -   action: sync
                path: ./
                target: ./

    serviceb:
        build: .
        develop:
            watch:
            -   action: sync
                path: ./
                target: ./

    servicec:
        build: .
        depends_on:
        -   servicea
        develop:
            watch:
            -   action: sync
                path: ./
                target: ./
  1. Execute docker compose watch servicec

Compose Version

v2.27.0

Docker Environment

Client: Docker Engine - Community
 Version:    26.1.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 3
  Running: 0
  Paused: 0
  Stopped: 3
 Images: 52
 Server Version: 26.1.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: sysbox-runc io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e377cd56a71523140ca6ae87e30244719194a521
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.5.0-28-generic
 Operating System: Ubuntu 22.04.4 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.06GiB
 Name: mtrepte
 ID: e3cb678a-bf3f-4bd7-86cc-a08e916d048d
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Default Address Pools:
   Base: 172.25.0.0/16, Size: 24

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions