Allow disabling ports (for merging multiple compose files)
Is your feature request related to a problem? Please describe.
When calling docker-compose with multiple files for separate environments and want to override port settings, you can't and you'll have to duplicate the files or do another sort of black magic.
Describe the solution you'd like
Allow ports to contain none-mappings that override previous mappings in the array.
In other words, this:
services:
my-service:
ports:
- 5000:6000
- 1234:1234
- 1234:none
Should have the same behavior as this:
services:
my-service:
ports:
- 5000:6000
Describe alternatives you've considered
- Replacing the array instead of merging the two, but that is a breaking change.
- Using a suffix or prefix to indicate that you want to override (
ports_override). But that may require a bit of work. - Specifying
override_strategy: overwrite, which is a decent solution, but seems harder to implement and has a wider scope. (As discussed in #2260) - Using multiple compose files: Causes a lot of duplication and makes it harder to start an app with one command.
- Search/replace and piping the file to docker-compose, but that is hacky and ugly.
This could be done in compose/config/config.py in process_ports I believe. New to the code base and my Python is getting rusty.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This could be also a good solution for #3729.
This issue has been automatically marked as not stale anymore due to the recent activity.
That's an interesting proposal. Should be discussed under Compose Specification (https://github.com/compose-spec/compose-spec)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
👋🏼
This issue has been automatically closed because it had not recent activity during the stale period.
🍀
This was not solved - please reopen