Skip to content

[BUG] extends drops overriden attributes #13298

@litoj

Description

@litoj

Description

I have multiple docker compose files, each building on the previous one.
The middle one overrides the volumes array and the top one (extending the middle one) doesn't change volumes at all. However, when I try to launch it the container gets created without any volumes at all - not the original ones nor the overriding ones.

Steps To Reproduce

Create a compose file (c1) that extends c2 which overrides let's say the environment variables after extending c3 that has the original environment definition.

now You just need to set the cmd as a simple echo "${envvar}" (without it getting processed by compose) and observe that none of the values you defined are actually available. You can do the same with volumes

Compose Version

2.40.0

Docker Environment

Client:
 Version:    28.5.1
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc.)
    Version:  2.40.0
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 4
  Running: 1
  Paused: 0
  Stopped: 3
 Images: 5
 Server Version: 28.5.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  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
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 75cb2b7193e4e490e9fbdc236c0e811ccaba3376.m
 runc version: 
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.17.2-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 13.49GiB
 Name: IP5Pro
 ID: b212eea5-d719-4bf0-8f4e-60407358f8c9
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

my compose files:

# template.yml
services:
  database:
    image: ${PROXY:-docker.io}/postgres:17-alpine
    volumes:
      - /home/git-ci/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh

# local-test.yml
services:
  database:
    extends:
      file: ./template.yml
      service: database
    volumes: !override # works without the !override
      - ./init-db.sh:/docker-entrypoint-initdb.d/init-db.sh

# final one that you launch
services:
  database:
    extends:
      file: local-test.yml
      service: database

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions