# Clustering Dockerized Elasticsearch with multiple Docker Host

**URL:** <https://discuss.elastic.co/t/clustering-dockerized-elasticsearch-with-multiple-docker-host/193950>\
**Category:** Elasticsearch\
**Created:** [August 6, 2019, 7:30am UTC](https://discuss.elastic.co/t/clustering-dockerized-elasticsearch-with-multiple-docker-host/193950 "2019-08-06T07:30:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ts-kazuob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ts-kazuob/32/51799_2.png) [@ts-kazuob](https://discuss.elastic.co/u/ts-kazuob)\
**Post date:** [August 6, 2019, 7:30am UTC](https://discuss.elastic.co/t/clustering-dockerized-elasticsearch-with-multiple-docker-host/193950/1 "2019-08-06T07:30:30Z")

</div>

Trying to make it clustering with docker compose.  
I have two elasticsearch docker containers which are deployed in different Docker Hosts.

**docker-compose.yml for docker-container-1**

> ```
> services:
> elasticsearch:
> restart: always
> hostname: elasticsearch
> image: docker-elk/elasticsearch:1.0.0
> build:
> context: elasticsearch
> dockerfile: Dockerfile
> environment:
> discovery.type: zen
> ports:
> - 9200:9200
> - 9300:9300
> env_file:
> - ./elasticsearch/elasticsearch.env
> volumes:
> - elasticsearch_data:/usr/share/elasticsearch/data
> 
> ```

**docker-compose.yml for docker-container-2**

> ```
> services:
> elasticsearch:
> restart: always
> hostname: elasticsearch
> image: docker-elk/elasticsearch:1.0.0
> build:
> context: elasticsearch
> dockerfile: Dockerfile
> environment:
> discovery.type: zen
> ports:
> - 9200:9200
> - 9300:9300
> env_file:
> - ./elasticsearch/elasticsearch.env
> volumes:
> - elasticsearch_data:/usr/share/elasticsearch/data
> 
> ```

**elasticsearch.yml on the elasticsearch-docker-container-1 on the Docker-Host 1**

> xpack.security.enabled: true  
> cluster.name: es-cluster  
> node.name: es1  
> network.host: 0.0.0.0  
> node.master: true  
> node.data: true  
> transport.tcp.port: 9300  
> path.data: /usr/share/elasticsearch/data  
> path.logs: /usr/share/elasticsearch/logs  
> discovery.zen.minimum\_master\_nodes: 1  
> gateway.recover\_after\_nodes: 1  
> discovery.zen.ping.unicast.hosts: ["host1:9300", "host2:9300","host1:9200", "host2:9200"]  
> network.publish\_host: host1

**elasticsearch.yml on the elasticsearch-docker-container-2 on the Docker-Host 2**

> ```
> xpack.security.enabled: true
> cluster.name: es-cluster
> node.name: es2
> network.host: 0.0.0.0
> node.master: true
> node.data: true
> transport.tcp.port: 9300
> path.data: /usr/share/elasticsearch/data
> path.logs: /usr/share/elasticsearch/logs
> discovery.zen.minimum_master_nodes: 1
> gateway.recover_after_nodes: 1
> discovery.zen.ping.unicast.hosts: ["host1:9300", "host2:9300","host1:9200", "host2:9200"]
> network.publish_host: host2
> 
> ```

**Below is the result of GET /\_cluster/health?pretty and it shows that there is only one node.**

> ```
> {
> "cluster_name" : "dps_geocluster",
> "status" : "yellow",
> "timed_out" : false,
> "number_of_nodes" : 1,
> "number_of_data_nodes" : 1,
> "active_primary_shards" : 33,
> "active_shards" : 33,
> "relocating_shards" : 0,
> "initializing_shards" : 0,
> "unassigned_shards" : 30,
> "delayed_unassigned_shards" : 0,
> "number_of_pending_tasks" : 0,
> "number_of_in_flight_fetch" : 0,
> "task_max_waiting_in_queue_millis" : 0,
> "active_shards_percent_as_number" : 52.38095238095239
> }
> 
> ```

According to the document below at least three elasticsearch nodes are required.

> **[Node | Elasticsearch Guide \[6.5\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/modules-node.html)**

Each elasticsearch container should be at different Docker host?

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 3, 2019, 7:30am UTC](https://discuss.elastic.co/t/clustering-dockerized-elasticsearch-with-multiple-docker-host/193950/2 "2019-09-03T07:30:38Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
