-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Add override option to service configuration for ports #6213
Conversation
This adds the ability to explicitly override the ports configuration with a given docker-compose.override.yml. Signed-off-by: Johan M. von Behren <[email protected]>
As a side note, "ports" is an interesting case. I don't think
has any utility anyway (even if it does have a logical meaning). After the first The It is probably too late to revisit the e.g.:
could be overridden with
resulting in
Not sure how to go about deleting a port mapping. Perhaps
|
Any feedback on this @shin-? |
Thanks @jovobe for picking up and updating the previous PR. My issue with this and the previous proposals is that I find the design extremely confusing and UX extremely poor (same for #5354). If we're going ahead with such a significant change, I want us to get it right, and I don't think we've found the right answer yet. If you're invested in getting this resolved, would you be willing to create an issue dedicated to discussing the design for this feature? I'd start with an RFE to formalize what we're trying to achieve, and then we can start brainstorming what that looks like concretely in a Compose definition. |
I agree, and still think the solution is to move away from an array and towards a dict, which provides the end user with all possible override possibilities (without requiring an |
Was a design issue (as proposed in #6213 (comment)) ever opened? Coming at this now it seems to me that this is a usecase which would be best served these days by docker app where you would simply make the port a parameter. Given both of those I'm going to close this PR for now, if |
|
What purpose does closing this serve? |
This adds the ability to explicitly override the ports configuration with a given docker-compose.override.yml. This is manly an updated version of this PR: #3939
Problem
We have a
docker-compose.yml
which we want to modify by using adocker-compose.override.yml
. According to the docs [1] theports
section is overridden as follows:This is bad in some cases: What if the base file contains a port binding which we want to change? This is currently not possible.
Solution
Inspired by @CarstenHoyer, I used his idea to add a new field to the service configuration called
override
. In this field all override-fields can be set (currently onlyports
is supported). This causesdocker-compose
to ignore the port configuration from the base and only uses the override port configuration.Example
docker-compose.yml
docker-compose.override.yml
Before this PR the result would be:
with this PR the result will be:
Signed-off-by: Johan M. von Behren [email protected]
Resolves #2260 and #3729
[1]: https://docs.docker.com/compose/extends/#adding-and-overriding-configuration