-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore ability to override an included resource in compose.override.yaml #559
Conversation
Sorry to intervene here, but, generalizing the original bug report, I think that there's a simpler solution. Please bear with me. To begin with, I have v2.33.3 installed as a plugin (and used as reference), and v.2.24.5 installed in the PATH: $ docker compose version
Docker Compose version v2.23.3
$ docker-compose version
Docker Compose version v2.24.5
then, let's say I have an services:
included:
image: included
and it's ... included in include:
- path:
- included.yaml
services:
default:
image: default
nothing special yet, with both versions, I get the same result: $ # this diffs the outputs of the config command for both versions,
$ # while mirroring on stderr the output of the reference version
$ diff -q <(docker compose -f compose.yaml config | tee /dev/stderr) <(docker-compose -f compose.yaml config)
name: inc
services:
default:
image: default
networks:
default: null
included:
image: included
networks:
default: null
networks:
default:
name: inc_default
now, let's say that I have an services:
optional:
image: optional
and, when merged using $ diff -q <(docker compose -f compose.yaml -f optional.yaml config | tee /dev/stderr) <(docker-compose -f compose.yaml -f optional.yaml config)
name: inc
services:
default:
image: default
networks:
default: null
included:
image: included
networks:
default: null
optional:
image: optional
networks:
default: null
networks:
default:
name: inc_default
now, if I want to automate this I would include the optional service using services:
default:
image: default:override
included:
image: included:override
optional:
image: optional:override
and here comes the test case: $ ls -1 *.yaml
compose.override.yaml
compose.yaml
included.yaml
optional.yaml
override.yaml
$ diff -q <(docker compose config | tee /dev/stderr) <(docker-compose config)
services.default conflicts with imported resource
name: inc
services:
default:
image: default:override
networks:
default: null
included:
image: included:override
networks:
default: null
optional:
image: optional:override
networks:
default: null
networks:
default:
name: inc_default
Files /dev/fd/63 and /dev/fd/62 differ
$ # to make it clearer
$ docker compose config
name: inc
services:
default:
image: default:override
networks:
default: null
included:
image: included:override
networks:
default: null
optional:
image: optional:override
networks:
default: null
networks:
default:
name: inc_default
$ docker-compose config
services.default conflicts with imported resource
So, I think that the include mechanism, can be viewed as a special case of using multiple That is:
Yet, I think that another solution would be to give up on the additional constraint,
But, it's just an opinion, and it conflicts with the view that the included services are sealed. And to finish, I really appreciate your work, and (but I can't recollect where) |
Oh, here's the content of include:
- path:
- optional.yaml
- override.yaml
|
15265eb
to
12e2258
Compare
@luciangabor what you describe here would make |
…yaml Signed-off-by: Nicolas De Loof <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
12e2258
to
6cc5ed3
Compare
This restore the (de facto) feature to override an included resource definition using a
compose.override.yaml
file. Also need to document this pattern so that this doesn't just work by chance and users can safely rely on it.closes docker/compose#11404