compose: [BUG] cycle detected at path with anchors

Description

docker compose up -d returns:

cycle detected at path: x-common-keys-dns-network

This worked before 2.30.0

Steps To Reproduce

this is my docker-compose.yml:

# Common environment values
x-environment: &default-tz-puid-pgid
  TZ: $TZ
  PUID: $PUID
  PGID: $PGID

x-common-keys-dns: &common-keys-dns
  dns:
   - 1.1.1.1
   - 1.0.0.1

x-common-keys-dns-network: &common-keys-dns-network
  <<: *common-keys-dns
  networks:
    - t2_proxy
...
services:
...
  mariadb:
    <<: *common-keys-dns-network
    image: ghcr.io/linuxserver/mariadb
    container_name: mariadb
    environment:
      <<: *default-tz-puid-pgid
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    healthcheck:
      test:  "/usr/bin/mysql --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} --execute \"SELECT 1;\""
      # test: "/usr/local/mysql/bin/mysql --user=foo --password=foo --execute \"SHOW DATABASES;\""
      interval: 10s
      timeout: 1s
      retries: 5
    ports:
      - '3306:3306'
    volumes:
      - '/mnt/data/mariadb:/var/lib/mysql:Z'
      - '${HOME}/docker/mariadb:/config'
    restart: unless-stopped

Compose Version

v2.30.0

Docker Environment

Client: Docker Engine - Community Version: 27.3.1 Context: default Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.17.1 Path: /usr/libexec/docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.30.0 Path: /usr/local/lib/docker/cli-plugins/docker-compose

Server: Containers: 41 Running: 41 Paused: 0 Stopped: 0 Images: 65 Server Version: 27.3.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: active NodeID: mzspegqexo7ka7bwccebn09on Is Manager: true ClusterID: 2qn2wroe2sinvydtudxjesbk7 Managers: 3 Nodes: 5 Default Address Pool: 10.0.0.0/8 SubnetSize: 24 Data Path Port: 4789 Orchestration: Task History Retention Limit: 5 Raft: Snapshot Interval: 10000 Number of Old Snapshots to Retain: 0 Heartbeat Tick: 1 Election Tick: 10 Dispatcher: Heartbeat Period: 5 seconds CA Configuration: Expiry Duration: 3 months Force Rotate: 0 Autolock Managers: false Root Rotation In Progress: false Node Address: 192.168.1.132 Manager Addresses: 192.168.1.103:2377 192.168.1.132:2377 192.168.1.140:2377 Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c runc version: v1.1.14-0-g2c9f560 init version: de40ad0 Security Options: apparmor seccomp Profile: builtin cgroupns Kernel Version: 6.11.0-9-generic Operating System: Ubuntu 24.10 OSType: linux Architecture: x86_64 CPUs: 6 Total Memory: 30.69GiB Name: nuc ID: 5ddf237a-7f91-4942-8702-6ce95a3666d7 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 2 years ago
  • Reactions: 11
  • Comments: 25 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Hello, I’ve probably found an edge case. The issue reproduces on main branch with this config:

services:
  assets: &assets
    image: node:20

  build:
    <<: *assets
    command: echo hello from build

  build.uk:
    <<: *assets
    command: echo hello from build.uk
./bin/build/docker-compose version
Docker Compose version v2.30.3-19-g5e3a09538

./bin/build/docker-compose run --rm build.uk
cycle detected: node at path services.build.uk references node at path services.build

My guess it is because of the . in the service name

Could you try this one? docker-compose.zip

p.s. generally keep in mind, that it’s not a good idea to use binary from an unknown person because I can inject anything to the code)

Thanks a lot for the quick fix! ❤

Edit: I can confirm that everything works fine now!

@douglas you can download the official release with the fix now

@idsulik, thanks for providing the binary. No worries; I usually avoid it except for cases like this one 😉

I just tested your binary, and I can confirm it solves the problem 👍

Thanks again for quickly fixing the issue! Really appreciated ❤

pushed fix https://github.com/compose-spec/compose-go/pull/709

@douglas could you please provide your yaml config? I’ll check it as well

I’m having a similar bug after updating docker desktop a few hours ago. It’s running under docker compose v2.30.0 too.

The funny part is I’m only unable to run services with yaml anchors and aliases specifically inside Devcontainers, while using docker-outside-of-docker. Project runs fine on the WSL2 docker host.

$>docker compose --profile dev up
cycle detected at path: services.web-test.1

Outputs same message for any services using anchors and aliases in its definition.

@idsulik Cool thanks ! I will wait for the release then, good job =)

Is there another work around ?

You can try to change the config file to make it referenceless or wait until the next release with the fix(@glours FYI)

I’m having the the same error on 2.30.2 using the following minimal compose file:

# Fragments
x-common:
  &common
  restart: unless-stopped


# Services
services:

  backend:
    <<: *common
    image: alpine:latest

  backend-static:
    <<: *common
    image: alpine:latest

  backend-worker:
    <<: *common
    image: alpine:latest

Output:

➜ docker compose up
cycle detected at path: services.backend

I’m happy to test further things if this helps 👍

The error happens again on 2.30.2

works well on 2.30.1

@idsulik using 2.30.1 and still having this cycle detected at path issue. Worked prior to 2.30.

Image

minimal compose
########################### NETWORKS
networks:
  default:
    driver: bridge
  reverse_proxy:
    external: false
    name: reverse_proxy
    ipam:
      config:
        - subnet: ${REVERSE_PROXY_SUBNET}
          gateway: ${REVERSE_PROXY_GATEWAY}

########################### SECRETS
secrets:
 ############################# VPNS
  # Proxy auth
  vpn_proxy_username:
    file: $SECRETSDIR/vpn_proxy_username
  vpn_proxy_password:
    file: $SECRETSDIR/vpn_proxy_password
  # PIA
  vpn_pia_username:
    file: $SECRETSDIR/vpn_pia_username
  vpn_pia_password:
    file: $SECRETSDIR/vpn_pia_password

########################### TEMPLATES
x-templates:
 # Gluetun
  x-gluetun: &gluetun
    container_name: gluetun-template
    image: ghcr.io/qdm12/gluetun:v3
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    networks:
      reverse_proxy:
    environment: &gluetun_env
      #### https://github.com/qdm12/gluetun/wiki/Environment-variables
      #### System
      TZ: "$TZ"
      PUID: "$PUID"
      PGID: "$PGID"
      #### VPN
      PUBLICIP_FILE: "/gluetun/ip"
      #### DNS over TLS
      DOT: "on" # default on
      DNS_UPDATE_PERIOD: "0" # default 24h. Period to update block lists and cryptographic files and restart Unbound. Set to 0 to deactivate updates.
      BLOCK_MALICIOUS: "on" # default on
      BLOCK_SURVEILLANCE: "off" # default off
      BLOCK_ADS: "off" # default off
      #### HTTP proxy
      HTTPPROXY: "on"
      HTTPPROXY_LOG: "off" # default off
      HTTPPROXY_LISTENING_ADDRESS: ":1080" # default 8888. change to 1080 so curl's default proxy port matches container
      # HTTPPROXY_USERNAME: ""
      # HTTPPROXY_PASSWORD: ""
      HTTPPROXY_USER_SECRETFILE: "/run/secrets/vpn_proxy_username"
      HTTPPROXY_PASSWORD_SECRETFILE: "/run/secrets/vpn_proxy_password"
      HTTPPROXY_STEALTH: "off" # default off
      #### HTTP Control server
      HTTP_CONTROL_SERVER_ADDRESS: ":8000" # default :8000
      HTTP_CONTROL_SERVER_LOG: "on" # default on
      #### Other
      # HEALTH_TARGET_ADDRESS: "1.1.1.1" # default cloudflare.com:443
      PUBLICIP_PERIOD: "12h" # default 12h. period to check for public IP address. set to 0 to disable.
      VERSION_INFORMATION: "off" # default on. Logs a message indicating if a newer version is available once the VPN is connected.
      UPDATER_PERIOD: "0" # default 0. Period to update all VPN servers information in memory and to /gluetun/servers.json.
    tmpfs:
      - /tmp
    volumes: &gluetun_volumes
      - $CONTDIR/gluetun/servers.json:/gluetun/servers.json
    labels: &gluetun_labels
     ## Deunhealth
      deunhealth.restart.on.unhealthy: true
     ## unRAID
      net.unraid.docker.managed: "compose"
      net.unraid.docker.icon: $CONTDIR/_unraid-icons/gluetun.png
  x-gluetun-pia: &gluetun_pia
    <<: *gluetun
    secrets:
      - vpn_proxy_username
      - vpn_proxy_password
      - vpn_pia_username
      - vpn_pia_password
  x-gluetun-env-pia: &gluetun_env_pia
    <<: *gluetun_env
    #### VPN HOST
    VPN_SERVICE_PROVIDER: "private internet access"
    OPENVPN_USER_SECRETFILE: "/run/secrets/vpn_pia_username"
    OPENVPN_PASSWORD_SECRETFILE: "/run/secrets/vpn_pia_password"
    # SERVER_REGIONS: ""
    # PRIVATE_INTERNET_ACCESS_VPN_PORT_FORWARDING: "off"
    # PRIVATE_INTERNET_ACCESS_VPN_PORT_FORWARDING_STATUS_FILE : "/gluetun/forwarded_port"

########################### SERVICES
services:
 ########################### VPNS
 # PIA
  # vp0 - CA Ontario (CA Toronto)
  vp0:
    <<: *gluetun_pia
    container_name: vp0
    ports:
      - $DOCKERHOSTIP:${VPN_PORT}50:1080
    environment:
      <<: *gluetun_env_pia
      SERVER_REGIONS: "CA Ontario"
      VPN_PORT_FORWARDING: "on"
      VPN_PORT_FORWARDING_STATUS_FILE: "/gluetun/forwarded_port.dat"
      UPDATER_PERIOD: "24h"
      UPDATER_VPN_SERVICE_PROVIDERS: "private internet access,windscribe,vpn unlimited"
    volumes:
      - $CONTDIR/gluetun/vp0:/gluetun
      - $CONTDIR/gluetun/servers.json:/gluetun/servers.json
      # - <<: *gluetun_volumes
    labels:
      <<: *gluetun_labels
     ## Diun
      diun.enable: true
      diun.watch_repo: true
      # diun.notify_on: new
      diun.include_tags: ^v\\d+$$

Thank you for the issue, the fix is ready https://github.com/compose-spec/compose-go/pull/704