Skip to content

[BUG] depends_on condition does not override correctly #11993

@scnewma

Description

@scnewma

Description

When overriding a short-hand version of depends_on with a long-form version and changing the condition on a subset of the dependencies, the resulting configuration applies the condition override to all dependencies instead of only the overridden dependency

Steps To Reproduce

  1. Create two compose files:

base.yml

name: test
services:
  test:
    image: test
    depends_on:
      - foo
      - bar
  foo:
    image: foo
  bar:
    image: bar

override.yml

services:
  test:
    image: test
    depends_on:
      foo:
        condition: service_completed_successfully
  1. Print the effective configuration
❯ docker compose -f base.yml -f override.yml config
name: test
services:
  bar:
    image: bar
    networks:
      default: null
  foo:
    image: foo
    networks:
      default: null
  test:
    depends_on:
      bar:
        condition: service_completed_successfully
        required: true
      foo:
        condition: service_completed_successfully
        required: true
    image: test
    networks:
      default: null
networks:
  default:
    name: test_default

The resulting configuration incorrectly applies the service_completed_successfully condition to both foo and bar, when it should have only applied to foo and bar should have gotten the default service_healthy condition.

Compose Version

Docker Compose version v2.27.0-desktop.2

Docker Environment

Client:
 Version:    26.1.1
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.0-desktop.1
    Path:     /Users/shaun/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.0-desktop.2
    Path:     /Users/shaun/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.29
    Path:     /Users/shaun/.docker/cli-plugins/docker-debug
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     /Users/shaun/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.23
    Path:     /Users/shaun/.docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     /Users/shaun/.docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.1.0
    Path:     /Users/shaun/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/shaun/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.8.0
    Path:     /Users/shaun/.docker/cli-plugins/docker-scout

Server:
 Containers: 12
  Running: 5
  Paused: 0
  Stopped: 7
 Images: 493
 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: cgroupfs
 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: 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:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.6.26-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 10
 Total Memory: 7.657GiB
 Name: docker-desktop
 ID: c437cf46-baab-4ed0-99ad-d12c01552179
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///Users/shaun/Library/Containers/com.docker.docker/Data/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile

Anything else?

We have confirmed that the behavior changed around v2.24.x - no versions newer than 2.24.x work (have tested the latest as well), but v2.23.0 works as expected.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions