[BUG] !reset is not correctly handled when used with extends and templates
Description
issue: using a template file which references its own services and uses !reset does not actually reset the value.
i tested all compose versions between 2.24.3 and 2.28.1.
- v2.24.3 is the last version i saw this working as expected.
- 2.24.4 and 2.24.5 fail to render the config with "Circular reference error"
- 2.24.6+ do not reset the value
all of the tested versions actually do reset the value, when only rendering the template (i.e. ./docker-compose -f compose.base.yml config)
compose.base.yml
services:
init:
image: alpine:latest
command: "sleep infinity"
test:
extends: { service: init }
command: !reset
compose.yml
services:
init:
extends:
file: compose.base.yml
service: init
test:
extends:
file: compose.base.yml
service: test
expectation: running docker-compose config, "!reset" is evaluated and the resulting service "test" does not have a command configured.
expected result (and 2.24.3 actually produces this):
name: test
services:
init:
command:
- sleep
- infinity
image: alpine:latest
networks:
default: null
test:
image: alpine:latest
networks:
default: null
networks:
default:
name: test_default
(note: 2.24.7 outputs different, but behaves the same)
actual result (which is produced by 2.24.6+):
name: test
services:
init:
command:
- sleep
- infinity
image: alpine:latest
networks:
default: null
test:
command:
- sleep
- infinity
image: alpine:latest
networks:
default: null
networks:
default:
name: test_default
as can be observed: the command value for "test" service is not reset.
the only workaround i found, was to specify "!reset" directly in compose.yml. but this limits reusability of already working configurations. and it actually breaks things when updating from 2.24.3.
also worth a mention: this is not happening when using compose.override.yml. meaning: if compose.base.yml is renamed to compose.yml and the overrides (which i did leave out in the example files above) are moved to compose.override.yml (dropping the "extends") the command is also correctly reset.
Steps To Reproduce
- create compose.base.yml file
- create compose.yml file
- run
docker-compose config
Compose Version
2.24.3
Docker Compose version v2.24.3
2.24.4
Docker Compose version v2.24.4
2.24.5
Docker Compose version v2.24.5
2.24.6
Docker Compose version v2.24.6
2.24.7
Docker Compose version v2.24.7
2.25.0
Docker Compose version v2.25.0
2.26.0
Docker Compose version v2.26.0
2.26.1
Docker Compose version v2.26.1
2.27.0
Docker Compose version v2.27.0
2.27.1
Docker Compose version v2.27.1
2.27.2
Docker Compose version v2.27.2
2.27.3
Docker Compose version v2.27.3
2.28.0
Docker Compose version v2.28.0
2.28.1
Docker Compose version v2.28.1
Docker Environment
Client: Docker Engine - Community
Version: 26.0.0
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.13.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.25.0
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 17
Running: 15
Paused: 0
Stopped: 2
Images: 37
Server Version: 26.0.0
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: cgroupfs
Cgroup Version: 1
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: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 5.15.90.1-microsoft-standard-WSL2+
Operating System: Debian GNU/Linux 11 (bullseye)
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 29.32GiB
Name: garfield-work-wsl
ID: a38a12dd-a1dd-49b2-9707-270e4b6cc023
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
Anything else?
No response
Thanks for reporting this, I'll look into this ASAP