Files
Guillaume Lours 8018a96fde feat(compose): warn on unsupported compose-file attributes
Compose silently ignored several spec-valid attributes it doesn't
honor outside Swarm mode: deploy.update_config, credential_spec,
ports[].mode: host, and others had no visible effect on a plain
`docker compose up`.

Detection is wired into compose-go's loader as a fail-closed
allowlist: every attribute path the schema declares, minus the
handful this runtime deliberately doesn't implement, plus a few
value-conditional checks for attributes only unsupported for one
specific value. A newly-specified attribute gets flagged
automatically, with no corresponding code change needed here.

Depends on an unreleased compose-go change; go.mod carries a
temporary replace to a fork branch until it's released.

Signed-off-by: Guillaume Lours <[email protected]>
2026-09-09 16:32:04 +02:00

83 lines
1.9 KiB
YAML

services:
# Baseline: deploy.resources/replicas/restart_policy ARE honored outside
# Swarm, a port without an explicit mode defaults to mode: ingress, and
# label_file is resolved into real labels by compose-go's loader by
# default — none of these must ever produce a warning.
clean:
image: alpine
deploy:
replicas: 2
resources:
limits:
cpus: "0.50"
memory: 128M
restart_policy:
condition: on-failure
ports:
- "9090:90"
label_file:
- ./labels.env
# Every deploy.* sub-attribute that's silently ignored outside Swarm.
swarm-attrs:
image: alpine
credential_spec:
file: ./creds.json
deploy:
mode: replicated
labels:
team: backend
update_config:
parallelism: 1
failure_action: rollback
rollback_config:
parallelism: 1
placement:
constraints:
- node.role==manager
endpoint_mode: vip
# ports[].mode: host is Swarm-only.
ports-demo:
image: alpine
ports:
- target: 80
published: "8080"
mode: host
# volumes[].type: cluster (CSI) has no effect outside Swarm.
cluster-vol:
image: alpine
volumes:
- type: cluster
source: my-csi-volume
target: /data
# configs/secrets file-reference uid/gid/mode are ignored outside Swarm.
file-refs:
image: alpine
configs:
- source: myconfig
uid: "1000"
gid: "1000"
mode: 0o440
secrets:
- source: mysecret
uid: "1000"
gid: "1000"
mode: 0o440
configs:
myconfig:
file: ./myconfig.txt
labels:
team: backend # configs[].labels: reachable and flagged
secrets:
mysecret:
file: ./mysecret.txt
driver_opts: # secrets[].driver_opts: reachable and flagged (unlike configs)
region: eu-west
labels:
team: backend