Skip to content

Fragments/compose.override: merging multiple extensions in a docker-compose.override only merges the first extension #13154

@mushrowan

Description

@mushrowan

Description

Take the following docker-compose:

services:
  myservice:
    image: busybox
    environment:
      value1: docker-compose
      value2: docker-compose

And the following docker-compose.override.yml:

x-merge: &merge
  environment:
    value1: overridden
x-secondmerge: &secondmerge
  environment:
    value2: overridden

services:
  myservice:
    <<: [*merge, *secondmerge]

docker compose config prints the config as:

services:
  myservice:
    environment:
      value1: overridden
      value2: docker-compose
    image: busybox
    networks:
      default: null

The expected output, if I'm not misunderstanding, should be:

services:
  myservice:
    environment:
      value1: overridden
      value2: overridden
    image: busybox
    networks:
      default: null

Steps To Reproduce

  1. Make a directory with the first two snippets as docker-compose.yml and docker-compose.override.yml respectively.
  2. Run docker compose config
  3. See output

Compose Version

Docker Compose version 2.39.1

Docker Environment

❯ docker info
Client:
 Version:    28.3.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.26.1
    Path:     /nix/store/b0qfs2xnz1ll58byl0xr0v8bfsrs9hcg-docker-plugins/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.39.1
    Path:     /nix/store/b0qfs2xnz1ll58byl0xr0v8bfsrs9hcg-docker-plugins/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 28.3.3
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 Logging Driver: journald
 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: refs/tags/v2.1.4
 runc version:
 init version:
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.41
 Operating System: NixOS 25.11 (Xantusia)
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 27.15GiB
 Name: termina
 ID: 0a7f2dad-6180-40b2-88aa-1f26c1f45c67
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: redacted
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

I was able to reproduce this on an Ubuntu environment too, so this isn't a Nix issue.

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