Improve adding of port bindings#87
Merged
marcuslinke merged 4 commits intodocker-java:masterfrom Nov 5, 2014
Merged
Conversation
The use of Ports for adding port bindings requires knowledge of the internal data structure used for storing port bindings in Docker API. This commit adds a more intuitive alternative that works like the --publish option of the Docker CLI and some builder methods like withBinds(Bind...) and withLinks(Link...).
This allows you to use textual port binding specifications in the format
used by the Docker CLI in docker-java:
StartContainerCmd.withPortBindings(PortBinding.parse("80:8080/tcp"));
In Docker API, an undefined IP address is expressed as "". This is not intuitive and should be hidden from the user. Likewise, docker-java uses 0 for an unspecified port number. This also is not intuitive, especially if you consider that 0 is a legal port number. This change makes the undefinedness explicit by using null in both cases. When serializing, "" is used instead of null. This implies changing the type of hostPort from int to Integer.
albers
added a commit
to albers/docker-build-step-plugin
that referenced
this pull request
Nov 4, 2014
marcuslinke
added a commit
that referenced
this pull request
Nov 5, 2014
Improve adding of port bindings
Contributor
|
@albers Thanks! |
albers
added a commit
to albers/docker-build-step-plugin
that referenced
this pull request
Nov 5, 2014
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding port bindings involves the creation of a Ports object that has a confusing notion of bindings: in order to add a port binding, you
Ports.bindaBindingand hand it over towithPortBinding.Other builder methods offer more intuitive idioms that directly correspond to Docker CLI options, e.g.
withBinds(Bind...)andwithLinks(Link...).With this PR, you can do things like
The old way of working with
Portsstill exists. Querying port bindings from anInspectContainerResponsewas not changed.See individual commit messages for details.