Skip to content
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

Use host port 0 when setting up PortBindings #4396

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ private void applyConfiguration(CreateContainerCmd createCommand) {
// First collect all the randomized host ports from our 'exposedPorts' field
for (final Integer tcpPort : exposedPorts) {
ExposedPort exposedPort = ExposedPort.tcp(tcpPort);
allPortBindings.put(exposedPort, new PortBinding(Ports.Binding.empty(), exposedPort));
allPortBindings.put(exposedPort, new PortBinding(Ports.Binding.bindPort(0), exposedPort));
}
// Next collect all the fixed host ports from our 'portBindings' field, overwriting any randomized ports so that
// we don't create two bindings for the same container port.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static String start(DockerClient client) {
.withHostConfig(
new HostConfig()
.withAutoRemove(true)
.withPortBindings(new PortBinding(Ports.Binding.empty(), ryukExposedPort))
.withPortBindings(new PortBinding(Ports.Binding.bindPort(0), ryukExposedPort))
)
.withExposedPorts(ryukExposedPort)
.withName("testcontainers-ryuk-" + DockerClientFactory.SESSION_ID)
Expand Down