Method of exposing UDP port changed in 1.16.0
See original GitHub issueI am upgrading from: TestContainers 1.15.3 -> 1.16.2 Docker-Java 3.2.8 -> 3.2.12
In order to expose a UDP port, users are required to access the underlying docker-java command, and modify it to expose the desired port. In my project I am doing this using a custom container class and overwriting the configure()
method as follows:
public class KerberosContainer extends GenericContainer<KerberosContainer> {
@Override
protected void configure() {
withExposedPorts(99, 464, 749); //TCP ports
withNetworkAliases(KRB5_KDC);
withCreateContainerCmdModifier(cmd -> {
List<ExposedPort> ports = new ArrayList<>();
for (ExposedPort p : cmd.getExposedPorts()) {
ports.add(p);
}
ports.add(new ExposedPort(99, InternetProtocol.UDP));
cmd.withExposedPorts(ports);
cmd.withHostName(KRB5_KDC);
});
}
}
Once the container is started, I try to extract the mapped port using the InspectContainerResponse
object as follows:
@Override
protected void containerIsStarted(InspectContainerResponse containerInfo) {
NetworkSettings networkSettings = containerInfo.getNetworkSettings();
Ports ports = networkSettings.getPorts();
Map<ExposedPort, Binding[]> map = ports.getBindings();
Binding[] bindings = map.get(new ExposedPort(99, InternetProtocol.UDP));
Binding binding = bindings[0]; //NullPointerException
String udp99 = binding.getHostPortSpec();
udp_99 = Integer.valueOf(udp99);
}
A NullPointerException is thrown because the withCreateContainerCmdModifier
was not honored.
This is apparent when inspecting the container created directly with docker:
And printing out the contents of the bindings map at runtime
{
749/tcp=[Lcom.github.dockerjava.api.model.Ports$Binding;@3bcb01f9,
464/tcp=[Lcom.github.dockerjava.api.model.Ports$Binding;@defb0e3a,
99/tcp=[Lcom.github.dockerjava.api.model.Ports$Binding;@15c64f5f,
99/udp=null,
88/tcp=null
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Using AWS NLB manually targeting an EKS Service exposing ...
Problem encountered with EKS 1.16. If we try to create a service of type Network Load Balancer (NLB) for UDP traffic we can...
Read more >Nginx-Ingress Helm Deployment --tcp-services-configmap ...
I'm trying to do TCP/UDP port-forwarding with an ingress. ... Here you can clearly see its an argument of the controller: --tcp-services-configmap ...
Read more >The default dynamic port range for TCP/IP has changed in ...
This article describes the changes to the default dynamic port range for TCP/IP in Windows Vista and in Windows Server 2008.
Read more >Hacking VoIP Exposed - Black Hat
a popular way of finding bugs and vulnerabilities. • Fuzzing involves creating different types of packets for a protocol which contain data that...
Read more >PgBouncer changelog
Change auth_type in sample pgbouncer.ini to md5 to match the built-in default. ... 2021-08-09 - PgBouncer 1.16.0 - “Fended off a jaguar”.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Putting “wontfix” here because it isn’t a breaking change but an assumption that got changed. We never guaranteed that we will bind ports that were added through
withCreateContainerCmdModifier
and going that route means that now you are dealing with Docker’s low level API and need to understand how it behaves.Thanks @KyleAure, your help is much appreciated 🙌