compose icon indicating copy to clipboard operation
compose copied to clipboard

[BUG] Docker compose does not ignore extension fields under long form depends_on

Open LelouBil opened this issue 1 year ago • 0 comments

Description

When adding an extension field (starting with x-) under a depends_on long form element, compose gives an "Additional property is not allowed" error, whereas everywhere else it ignores it (as specified in the documentation and reference)

https://docs.docker.com/compose/compose-file/11-extension

Compose ignores any fields that start with x-, this is the sole exception where Compose silently ignores unrecognized fields. They also can be used within any structure in a Compose file where user-defined keys are not expected.

Steps To Reproduce

  1. Have a working docker-compose
  2. Use this example docker-compose.yaml file
x-ignored: test

services:
  nginx:
    image: nginx:latest
    x-other-ignore: true
    depends_on:
      other_nginx:
        condition: service_started
        x-not-ignored: bug
  other_nginx:
    image: nginx:latest
  1. docker compose up
  2. validating /tmp/test/docker-compose.yml: services.nginx.depends_on.other_nginx Additional property x-not-ignored is not allowed

Compose Version

Docker Compose version v2.27.0

Docker Environment

Client: Docker Engine - Community
 Version:    26.1.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 18
  Running: 16
  Paused: 0
  Stopped: 2
 Images: 67
 Server Version: 26.1.2
 Storage Driver: overlay2
  Backing Filesystem: btrfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: loki
 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: 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:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.1.0-21-amd64
 Operating System: Debian GNU/Linux 12 (bookworm)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.749GiB
 Name: staging
 ID: ea0d18d1-a91d-4022-8065-ad7026d0083c
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 174
  Goroutines: 172
  System Time: 2024-06-22T15:13:54.57807414+02:00
  EventsListeners: 0
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

Maybe I should file it with https://github.com/compose-spec/compose-go ? I see their https://github.com/compose-spec/compose-go/blob/main/schema/compose-spec.json doesn't have a key "patternProperties": {"^x-": {}} for the long form depends_on whereas it is present for most of the other objects in the file

LelouBil avatar Jun 22 '24 13:06 LelouBil