Reputation: 97
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.
Upvotes: 1
Views: 125
Reputation: 38
docker run -d -p 9300:9300 --name es1 elasticsearch
docker run -d -p 9301:9300 --name es2 elasticsearch
docker run -d -p 9302:9300 --name es3 elasticsearch
docker run -d -p 9303:9300 --name es4 elasticsearch
Now you have 4 elasticsearch containers
Upvotes: 1