compose: [BUG] Regression: array items[0,1] must be unique starting from 2.24.1

Description

As per the subject, starting from 2.24.1, I am encountering this issue when there are overrides.

Steps To Reproduce

Create 2 files:

  1. docker-compose.yaml
version: "3.8"

services:
  test:
    image: ubuntu:latest
    command: sleep infinity
    volumes:
      - ./src:/src
  1. docker-compose.override.yaml
services:
  test:
    volumes:
      - ./src:/src

WIth 2.23.3:

❯ dc version
Docker Compose version 2.23.3
❯ dc down -v

With 2.24.1:

❯ ./dc-2.24.1 version
Docker Compose version v2.24.1
❯ ./dc-2.24.1 down -v
validating /home/paolo/temp/dc-compose/docker-compose.override.yml: services.test.volumes array items[0,1] must be unique

Compose Version

Docker Compose version v2.24.1

Docker Environment

❯ docker info
Client:
 Version:    24.0.7
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.12.1
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.23.3
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 15
  Running: 9
  Paused: 0
  Stopped: 6
 Images: 141
 Server Version: 24.0.7
 Storage Driver: btrfs
  Btrfs:
 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 logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 71909c1814c544ac47ab91d2e8b84718e517bb99.m
 runc version:
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.6.11-2-lts
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 24
 Total Memory: 30.49GiB
 Name: paolo-cto-arch-wood
 ID: ZRJM:NTZC:JCYV:OSU3:VB2H:N2CW:ZCLD:PCGW:JGT5:B2BR:445A:GEHV
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 15
  • Comments: 59 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Even with extra_hosts.

Docker Desktop 4.27.2 luckily fixed the issues for us!

Hello everyone 👋

We need your help to verify that we managed most of the problems you faced with the v2.24.x releases

I created a PR with the current fixes of merge issues, can you try it and let us know if you still have problem we didn’t already solved? Unfortunately you’ll have to download all the binaries but choose the right one for your platform and add it to your ~/.docker/cli-plugins/ directory with the name docker-compose

We already know there is a problem with the networks.config.subnet a fix is in progress for this one

This is working fine with v2.24.2 - the duplicate environment entries is working too, so the fix did cover that.

Right. The issue continues appearing with links and profiles though. Here is the repro:

main.yml:

name: my-project
services:
  myfirstservice:
    image: alpine:latest
  myservice:
    image: alpine:latest
    environment:
      - MYVAR=MyVarValue
    links:
      - myfirstservice
    profiles:
      - profile1
      - profile2

secondary.yml:

cat secondary.yml
name: my-project
services:
  myservice:
    extends:
      file: ${PWD}/main.yml
      service: myservice

command:

docker compose -f main.yml -f secondary.yml up

Hello all,

This is just in case this scenario was not covered by PR 533. Here is a simple case where docker compose complains about the environments setting (services.myservice.environment array items[0,1] must be unique):

main.yml

services:
  myservice:
    image: alpine:latest
    environment: 
      - MYVAR=MyVarValue

secondary.yml:

name: my-project
services:
  myservice:
    extends:
      file: ${PWD}/main.yml
      service: myservice

command:

docker compose -f main.yml -f secondary.yml up

Edit: If that matters, I removed everything just to make the scenario simple. I need the second file to declare volumes to the service that are not always needed.

So, this is same thing?

validating /root/qfieldcloud/docker-compose.override.local.yml: services.app.environment array items[1,46] must be unique

version: '3.9'

services:

  app:
    build:
      args:
        - DEBUG_BUILD=1
    ports:
      # allow direct access without nginx
      - ${DJANGO_DEV_PORT}:8000
      - ${DEBUG_DEBUGPY_APP_PORT:-5678}:5678
    volumes:
      # mount the source for live reload
      - ./docker-app/qfieldcloud:/usr/src/app/qfieldcloud
    environment:
      DEBUG: 1
    command: python3 -m debugpy --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8000
    depends_on:
      - db

  worker_wrapper:
    scale: ${QFIELDCLOUD_WORKER_REPLICAS}
    build:
      args:
        - DEBUG_BUILD=1
    ports:
      - ${DEBUG_DEBUGPY_WORKER_WRAPPER_PORT:-5679}:5679
    environment:
      QFIELDCLOUD_LIBQFIELDSYNC_VOLUME_PATH: ${QFIELDCLOUD_LIBQFIELDSYNC_VOLUME_PATH}
    volumes:
      # mount the source for live reload
      - ./docker-app/qfieldcloud:/usr/src/app/qfieldcloud
      - ./docker-app/worker_wrapper:/usr/src/app/worker_wrapper
    command: python3 -m debugpy --listen 0.0.0.0:5679 manage.py dequeue

  smtp4dev:
    image: rnwood/smtp4dev:v3
    restart: always
    ports:
      # Web interface
      - ${SMTP4DEV_WEB_PORT}:80
      # SMTP server
      - ${SMTP4DEV_SMTP_PORT}:25
      # IMAP
      - ${SMTP4DEV_IMAP_PORT}:143
    volumes:
        - smtp4dev_data:/smtp4dev
    environment:
      # Specifies the server hostname. Used in auto-generated TLS certificate if enabled.
      - ServerOptions__HostName=smtp4dev

  db:
    image: postgis/postgis:13-3.1-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    ports:
      - ${HOST_POSTGRES_PORT}:5432
    command: ["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]

  memcached:
    ports:
      - "${MEMCACHED_PORT}:11211"

  qgis:
    volumes:
      # allow local development for `libqfieldsync` if host directory present; requires `PYTHONPATH=/libqfieldsync:${PYTHONPATH}`
      - ./docker-qgis/libqfieldsync:/libqfieldsync:ro

  geodb:
    image: postgis/postgis:12-3.0
    restart: unless-stopped
    volumes:
      - geodb_data:/var/lib/postgresql
    environment:
      POSTGRES_DB: ${GEODB_DB}
      POSTGRES_USER: ${GEODB_USER}
      POSTGRES_PASSWORD: ${GEODB_PASSWORD}
    ports:
      - ${GEODB_PORT}:5432

  minio:
    image: minio/minio:RELEASE.2023-04-07T05-28-58Z
    restart: unless-stopped
    volumes:
      - minio_data1:/data1
      - minio_data2:/data2
      - minio_data3:/data3
      - minio_data4:/data4
    environment:
      MINIO_ROOT_USER: ${STORAGE_ACCESS_KEY_ID}
      MINIO_ROOT_PASSWORD: ${STORAGE_SECRET_ACCESS_KEY}
      MINIO_BROWSER_REDIRECT_URL: http://${QFIELDCLOUD_HOST}:${MINIO_BROWSER_PORT}
    command: server /data{1...4} --console-address :9001
    healthcheck:
        test: [
          "CMD",
          "curl",
          "-A",
          "Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0",
          "-f",
          "${STORAGE_ENDPOINT_URL}/minio/index.html"
        ]
        interval: 5s
        timeout: 20s
        retries: 5
    ports:
      - ${MINIO_BROWSER_PORT}:9001
      - ${MINIO_API_PORT}:9000

  createbuckets:
    image: minio/mc
    depends_on:
      minio:
        condition: service_healthy
    entrypoint: >
      /bin/sh -c "
      /usr/bin/mc config host add myminio ${STORAGE_ENDPOINT_URL} ${STORAGE_ACCESS_KEY_ID} ${STORAGE_SECRET_ACCESS_KEY};
      /usr/bin/mc mb myminio/${STORAGE_BUCKET_NAME};
      /usr/bin/mc policy set download myminio/${STORAGE_BUCKET_NAME}/users;
      /usr/bin/mc version enable myminio/${STORAGE_BUCKET_NAME};
      exit 0;
      "

volumes:
  postgres_data:
  geodb_data:
  smtp4dev_data:
  minio_data1:
  minio_data2:
  minio_data3:
  minio_data4:

I don’t mean to be a pain here, but I’m seeing similar on v2.25.0. Figured best to post on this thread versus a new issue as it seems related to my newb self?

“validating /home/docker/docker-compose.override.yml: services.scrutinyanalogj.devices array items[0,11] must be unique”

  scrutinyanalogj:
    ports:
      - '86:80'
      - '8886:8080'
    volumes:
      - '/home/docker/scrutinyanalogj:/opt/scrutiny/config'
      - '/home/docker/influxdb2:/opt/scrutiny/influxdb'
      - '/run/udev:/run/udev:ro'
    restart: always
    logging:
      options:
        max-size: 1g
    container_name: scrutinyanalogj
    environment:
      - PUID=1000
      - PGID=996
      - TZ=America/New_York
    devices:
      - '/dev/nvme0n1p1:/dev/nvme0'
      - '/dev/nvme1n1p1:/dev/nvme1'
      - '/dev/nvme2n1p1:/dev/nvme2'
      - '/dev/sda:/dev/sda'
      - '/dev/sdb:/dev/sdb'
      - '/dev/sdc:/dev/sdc'
      - '/dev/sdd:/dev/sdd'
      - '/dev/sde:/dev/sde'
      - '/dev/sdf:/dev/sdf'
      - '/dev/sdg:/dev/sdg'
      - '/dev/sdh:/dev/sdh'
    cap_add:
      - SYS_ADMIN
      - SYS_RAWIO
    image: ghcr.io/analogj/scrutiny:master-omnibus
    networks:
      vpnsys_net:
        ipv4_address: '172.22.0.109'

@solarlodge and all the others having issue with tmpfs, those binaries should fix your issue

@glours I can confirm that Docker Compose version d4fb179 does indeed fix all issues we had with the tmpfs array. so far. Every other aspect of our docker compose overwrite setup seems to work again. Many many thanks for your precious and highly appreciated work 🙏

@solarlodge and all the others having issue with tmpfs, those binaries should fix your issue

In my case, it is services.nginx.labels array items[2,7] must be unique and still happens with Docker Compose 2.24.2… Shouldn’t it be fixed with this version?

Here the very same issue with links and tmpfs…

@YtvwlD please open a new bug for this

Is this released? No milestone assigned…

@ihor-sviziev Yes they decided to focus on the security fixes for this release, a next patch release of Docker Desktop is planned for next week… Sorry for the delay, anyway you can add manually the binary of Compose v2.24.5 to your ~/.docker/cli-plugins directory with the name docker-compose

@matanmarciano no indeed, a release of https://github.com/docker/docker-ce-packaging is planned later this week

@glours I can confirm, the fixed version fixes this issue for me.

@ihor-sviziev yes because the signature of the binary for MacOs is done as part of the Docker Desktop release, you have to approve it manually in System settings>Privacy & Security You could use those binaries which use the v2.0.0-rc.3 release of compose-go

@glours is there any estimation where that fix will be released?

The issue with the services.*.labels array seems to be gone. The services.*.tmpfs array still gives the error msg validating *override*.yml: services.*.tmpfs array items[0,3] must be unique. Tested with Docker Compose version 41161da.

@glours, Thanks!

I confirm our full scenario works properly with the build you provided (Docker Compose version 41161da)

Thank you for getting back to me so promptly, @ndeloof. In my case, there seems to be no valid reason for the issue I’m facing. It appears to be a chain of docker-compose files where the last one is adding the same volumes again. Unfortunately, I cannot modify it as the base docker-compose files are managed by a custom framework.

In version <= 2.23, errors were ignored or overwritten silently. However, this is no longer the case, resulting in a breaking change.