javadockerdocker-networkdocker-java

Docker: Publishing ports from a user-defined network to a specific host IP address with docker-java


I'm trying to achieve something similar to this:

-p 192.168.1.100:8080:80

with docker-java. The only example that I found for publishing/mapping ports with docker-java is using the .withExposedPorts of the CreateContainerCmd class. here.

I'm not seeing any way of specifying a host IP address. I wonder if this is something supported from the docker-java project?


Solution

  • Have you tried with Binding.bindIpAndPort ?

    https://github.com/docker-java/docker-java/blob/638b2ad033a281160c6545eb30f1b7d014505905/src/main/java/com/github/dockerjava/api/model/Ports.java#L145