[BUG] extends
with YAML merge anchors will ignore !override and !reset
#11706
Labels
extends
with YAML merge anchors will ignore !override and !reset
#11706
Description
I think this might be two separate issues - please let me know and feel free to split it up.
End goal: 10+ containers use the
configs
entry with dummy data, so I need that to be inherited. However a small number (about 3) need a volume mount of real information, so I want those to override (but inherit from each other using YAML anchors/aliases) - these are represented byx
andy
in my example below..When a
volume
is in the same location as aconfig
, there is no error and it is undefined behaviour or a race condition as to which one is applied first. In my case, theconfig
is actually a sub-path of the volume, and the volume is read only, so if the volume wins, Compose reports an error when trying to deal with the config, otherwise it just works.Secondly, I have a complex inheritance system where
extends
is used in a YAML anchor. When declaring theconfigs
element with a!reset
or!override
directive, the newconfigs
declaration is lost/ignored when the alias is later referenced.Because I was unaware of the second issue, I was unknowingly running into the first issue (though I had explicitly tried to avoid it). Had Compose had a clearer error message, the second issue would have been easier to identify.
Steps To Reproduce
Files:
stuff/file1
andstuff/file2
->some random text
docker-compose.template.yml
docker-compose.yml
Try
docker compose up -d
.When the volume is mounted first (for container
y
), the race condition causes this error:Sometimes it will just work if the configs are applied first.
Compose Version
Docker Environment
Output of
docker info
Anything else?
docker compose config
outputYou can see that for service
y
, theconfigs
directive is a merge of bothbase
andx
while ignoring the!override
directive. A reset directive behaves the same way (it just inherits frombase
asx
is empty).The text was updated successfully, but these errors were encountered: