-
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
extending services should allow overwriting port bindings #11158
Comments
The result of
Still, something goes wrong with Compose with this same configuration as demonstrated with your reproducible example. |
With fresh new eyes on it I eventually understood the issue: test_api:
build:
context: /Users/nicolas/truc
dockerfile: ./Dockerfile
entrypoint:
- run_tests.sh
networks:
default: null
ports:
- mode: ingress
target: 8000
published: "50052"
protocol: tcp
- mode: ingress
target: 8000
published: "59999"
protocol: tcp As long as the extended service There's no way (for now) to configure the merge logic to just override value. An alternative approach is for you to use yaml anchors to share service definition and customize for each service: x-service: &common-definition
build:
context: .
dockerfile: ./Dockerfile
ports:
- "50052:8000"
services:
api:
<<: *common-definition
ports:
- "50052:8000"
entrypoint: python main.py
test_api:
<<: *common-definition
ports:
- "59999:8000" # same inner port
entrypoint:
- run_tests.sh As a side note, you should not declare |
Possible you should remove "ports" definition from shared anchor (x-service). |
For those finding this issue checkout this comment in issue 3729, which notes the (relatively) new |
Description
If service A has a port binding
("8000:8000")
, and service B extends service A and has a port binding to the same inner port but a different outer port("9000:8000")
, then if I run both services at the same time, I should not get aBind for 0.0.0.0:8000 failed: port is already allocated
. docker-compose should identify the overlapping inner port bindings in service B, and its new binding "9000:8000" should overwrite the inherited binding "8000:8000" for service B.My use case:
I have one service running, and I would like a neat way to run tests in an extension of that service without stopping the first service.
But running the test_api service while the api service is already running gives me the error
Bind for 0.0.0.0:50052 failed: port is already allocated
The text was updated successfully, but these errors were encountered: