Clarifying if I need to -p publish multiple Elasticsearch node ports in a multi-node cluster inside one Docker container

Hey Docker community! :waving_hand:

I’m running a local multi-node Elasticsearch cluster for study purposes, but using a very DIY setup: all nodes (node1, node2, node3) run inside a single Debian-based Docker container. I’m not using the official Elastic image — I’m manually installing everything from the .tar.gz binaries downloaded from elastic.co.

Here’s how I start the container:

docker run --privileged -dit `
   --name elastic-debian `
   --hostname elastic-learning `
   -p 9200:9200 `
   -v "D:\Docker\Volumes\elastic-data:/opt/elastic" `
   debian:11 tail -f /dev/null

Then, I docker exec into it and do everything manually — install packages, create users, extract the Elastic tarball, configure nodes, set ports, etc.

Each node runs in its own folder and listens on its own port:

  • node1: 9200 (published)
  • node2: 9201 (internal only)
  • node3: 9202 (internal only)

Everything is working great inside the container: the nodes form a cluster, /cat/nodes sees everyone, and Kibana (running externally) connects via localhost:9200 just fine.

My question is: Is there any real need to -p publish the other node ports (9201, 9202) externally, or is it fine to expose only node1’s port?

The idea is that node1 is acting as the coordinating node, and internally all other HTTP traffic between nodes stays inside the container. Since the cluster API is reachable through node1, my instinct says: “no need to publish the others.”

But I’d love confirmation from folks with Docker and networking experience: any admin/debug/monitoring use cases that would justify publishing other node HTTP ports? Or is this one-port setup perfectly acceptable for local clusters?

Also, if anyone wants to see the hilariously frustrating StackOverflow experience I had with this question being misunderstood and closed by people who read the word “expose” and lost their minds, here you go:

:link: Do I need to publish (-p) the HTTP ports of multiple Elasticsearch nodes running inside the same Docker container? - Stack Overflow

Thanks in advance to the Docker folks who actually read! :folded_hands:

Bmitch is right and I understand why your question was misunderstood on SackOverflow.. I wouldn’t have marked that topic as duplicate until I understood what the question is actually about, but it is true, the original question mentioned only exposing, which alone is not a reason for misunderstanding probably, but since you have a container in which you install everything, there is nothing Docker related in the question which could confuse people.

It is like installing three services in one virtual machine and asking about whether you need to forward an external port to all the internal ports or not. It all depends on what you need that port for. The services inside the container or VM can communicate with eachother, and you only need ports outside that isolated environment which you want to use. If you need all instances outside, you might want to forward ports to all.

If you need only one instance to use an API or webinterface, it still depends on the service. How it works, how it can synchronize data, which instance is allowed to accept requests and so on. In this case this would make the question an ElasticSearch and Kibana question which could be asked on the ElasticSearch forum, but from Docker perspective, it doesn’t matter.

If you ask my opinion, one instance should be enough, but you can check the ibana documentation

High availability across multiple Elasticsearch nodes

edit

Kibana can be configured to connect to multiple Elasticsearch nodes in the same cluster. In situations where > a node becomes unavailable, Kibana will transparently connect to an available node and continue operating. > Requests to available hosts will be routed in a round robin fashion (except for Dev Tools which will connect only to the first node available).

In kibana.yml:

elasticsearch.hosts:
  - http://elasticsearch1:9200
  - http://elasticsearch2:9200

So if you want high availability, you need multiple ports, if you don’t want HA, you don’t need multiple ports.