Open mattsouthern opened 3 months ago
Additionally would be nice if combining !reset
and yaml anchors like the following worked:
file1.yml
x-common-anchors:
app_name: &app_name app
services:
*app_name :
image: myapp
ports:
- "8080:80"
environment:
FOO: BAR
override.yml
x-common-anchors:
app_name: &app_name app
services:
*app_name :
image: myapp
ports: !reset []
environment:
FOO: !reset null
current output of docker compose -f file1.yml -f override.yml config
(!reset
tag not respected):
name: tests
services:
app:
environment:
FOO: BAR
image: myapp
networks:
default: null
ports:
- mode: ingress
target: 80
published: "8080"
protocol: tcp
networks:
default:
name: tests_default
x-common-anchors:
app_name: app
environment
is managed internally using the KEY=VALUE
representation during the merge phase, this is why !reset
doesn't work here. Not sure how this could be fixed...
would be nice if combining !reset and yaml anchors like the following worked:
anchor is a yaml syntax fature, applied by the low level yaml parser. This takes place before we merge yaml files together, so this is not possible
Description
When using multiple compose files with the
-f
option, each can define amendments to a service defined in a previous file. When the first two files define environment variables for a service, subsequent files are unable to use the!reset
tag to remove these environment key value pairs, per the example at https://docs.docker.com/compose/compose-file/13-merge/#reset-value. If only one file defines environment key value pairs then another is able to reset them as expected. This probably applies to other parts of the service definition but only theenvironment
key was tested.Steps To Reproduce
With the following files: test1.yml
test2.yml
override.yml
Run
docker compose -f test1.yml -f test2.yml -f override.yml config
Resulting in: (directory run in was named
tests
)Expected result would be:
Compose Version
Docker Environment
Anything else?
No response