0

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?

nikitz
  • 1,051
  • 2
  • 12
  • 35
  • I want to expose them only for the localhost of the host machine - 127.0.0.1. – nikitz Apr 16 '19 at 12:16
  • Then you can do something like [this](https://forums.docker.com/t/exposing-ports-only-to-localhost/20868/2). `-p 127.0.0.1:8080:80` – Thilak Apr 16 '19 at 12:19
  • I don't think you understand my problem here. I want to achieve this via the docker-java project and its API. https://github.com/docker-java/docker-java – nikitz Apr 16 '19 at 12:29

1 Answers1

1

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

Esteban Garcia
  • 2,171
  • 16
  • 24
  • 1
    Yes, this is what I found in the end of the day. Exactly what I needed! I will propose an edit to your question so that we can make it more helpful for other people and then we can accept it. :) – nikitz Apr 18 '19 at 12:30