X Tutup
Skip to content

Allow multiple port bindings per ExposedPort#82

Merged
marcuslinke merged 2 commits intodocker-java:masterfrom
albers:multiple-port-bindings
Oct 26, 2014
Merged

Allow multiple port bindings per ExposedPort#82
marcuslinke merged 2 commits intodocker-java:masterfrom
albers:multiple-port-bindings

Conversation

@albers
Copy link
Copy Markdown
Contributor

@albers albers commented Oct 26, 2014

docker-java currently maps the Docker API elements .HostConfig.PortBindings and .NetworkSettings.Ports to a Map<ExposedPort, Binding>. This is incorrect. There may be multiple Bindings per ExposedPort. The API element is an array.

To illustrate, create a container with docker run -d -p 80:80 -p 81:80 eboraas/apache:latest. Docker remote API will report

"PortBindings":{"80/tcp":[{"HostIp":"","HostPort":"80"},{"HostIp":"","HostPort":"81"}]}
"Ports":{"443/tcp":null,"80/tcp":[{"HostIp":"0.0.0.0","HostPort":"80"},{"HostIp":"0.0.0.0","HostPort":"81"}]}}

docker-java will only give you access to the first Binding, as shown by the test contributed in d1f31cd. There is no way to create multiple port bindings per ExposedPort with the current state of docker-java.

This PR changes the type used for storing port bindings to Map<ExposedPort, Binding[]>, solving both problems.

marcuslinke added a commit that referenced this pull request Oct 26, 2014
Allow multiple port bindings per ExposedPort
@marcuslinke marcuslinke merged commit b2d3db0 into docker-java:master Oct 26, 2014
@marcuslinke
Copy link
Copy Markdown
Contributor

@albers Thanks a lot!

@albers albers deleted the multiple-port-bindings branch October 26, 2014 18:50
albers added a commit to albers/docker-build-step-plugin that referenced this pull request Nov 4, 2014
@albers
Copy link
Copy Markdown
Contributor Author

albers commented Nov 7, 2014

Other projects have this API mismatch as well: docker/compose#624

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

X Tutup