Skip to content

Update ExposedPort to allow for port ranges#2618

Open
t-seemann wants to merge 1 commit into
docker-java:mainfrom
t-seemann:allow-portrange-expose
Open

Update ExposedPort to allow for port ranges#2618
t-seemann wants to merge 1 commit into
docker-java:mainfrom
t-seemann:allow-portrange-expose

Conversation

@t-seemann
Copy link
Copy Markdown

@t-seemann t-seemann commented Apr 24, 2026

The following Dockerfile is currently not mappable by ExposedPort:

FROM busybox

EXPOSE 8000-8080

CMD ["/bin/sh", "-c", "while true; do sleep 1; done"]

as the ranges can not be represented. Port ranges can only be continuous, therefore portRangeFrom and portRangeTo parameters were introduced to express such ranges.
Single exposed ports are represented by portRangeFrom = portRangeTo.

To be backwards compatibale the old getPort() getter returns the first port of the range.
This should in all old use cases always return the same port as before. The getter was set to deprecated as user should use the new getPortRangeFrom() and getPortRangeTo().


This change is Reviewable

@t-seemann t-seemann requested a review from a team as a code owner April 24, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants