I am connecting from elasticsearch client running in docker container to elasticsearch cluster (i.e. non dockerized). I am able to do this by having settings in the client as:
Settings settings = ImmutableSettings.settingsBuilder()
.put("node.name", "HelloESClient")
.put("discovery.zen.ping.multicast.enabled", false)
.put("discovery.zen.ping.unicast.hosts", "172.16.11.50")
.put("transport.publish_port", "9300")
.put("transport.publish_host", "192.168.17.131");
where 192.168.17.131:9300 is the host ip: port exposed for elasticsearch cluster to connect to the node client.
I cannot expose any other port in the host machine since 9300 port is the one set in elasticsearch config yml as tcp transport port.
The issue with this is that I am unable to start more than one docker container having elasticsearch client connecting to the same elasticsearch cluster since each container cannot expose the same port in the same machine.