# Running 2 node elasticsearch with docker compose yml file on a single machine

**URL:** https://discuss.elastic.co/t/running-2-node-elasticsearch-with-docker-compose-yml-file-on-a-single-machine/138668
**Category:** Elasticsearch
**Created:** [July 5, 2018, 8:36am UTC](https://discuss.elastic.co/t/running-2-node-elasticsearch-with-docker-compose-yml-file-on-a-single-machine/138668 "2018-07-05T08:36:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vinaypn](https://avatars.discourse-cdn.com/v4/letter/v/ed655f/32.png) [@vinaypn](https://discuss.elastic.co/u/vinaypn)
#### Post date: [July 5, 2018, 8:36am UTC](https://discuss.elastic.co/t/running-2-node-elasticsearch-with-docker-compose-yml-file-on-a-single-machine/138668/1 "2018-07-05T08:36:20Z")

</div>

Hi Team,

i am trying to run 2 node elasticsearch with a docker compose file.  
My docker-compose file looks like this:

version: '2'  
services:  
elasticsearch:  
image: elasticsearch  
volumes:  
- es\_data1:/usr/share/elasticsearch/data  
environment:  
- cluster.name=docker-cluster  
- http.host=0.0.0.0  
- transport.host=localhost  
- network.host=0.0.0.0  
- xpack.security.enabled=false  
- "ES\_JAVA\_OPTS=-Xms512m -Xmx512m"  
ulimits:  
memlock:  
soft: -1  
hard: -1  
mem\_limit: 1g  
networks:  
- esnet  
ports:  
- 9200:9200  
elasticsearch2:  
image: elasticsearch  
volumes:  
- es\_data2:/usr/share/elasticsearch/data  
environment:  
- cluster.name=docker-cluster  
- http.host=0.0.0.0  
- transport.host=localhost  
- network.host=0.0.0.0  
- xpack.security.enabled=false  
- "ES\_JAVA\_OPTS=-Xms512m -Xmx512m"  
- "discovery.zen.ping.unicast.hosts=127.0.0.1"  
ulimits:  
memlock:  
soft: -1  
hard: -1  
mem\_limit: 1g  
networks:  
- esnet  
ports:  
- 9201:9200  
- 9301:9300

volumes:  
es\_data1:  
driver: local  
es\_data2:  
driver: local

networks:  
esnet:

ERRORS:

1. The cluster name is not matching the one which was mentioned in the compose file (ie : docker-cluster)
2. The second node is not joining the first. Instead both are starting as master nodes.

PFB the output for cluster status:

root@smartThink-DTP:/home/vinayp/Desktop# curl [http://127.0.0.1:9200/\_cat/health?v](http://127.0.0.1:9200/_cat/health?v)  
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending\_tasks max\_task\_wait\_time active\_shards\_percent  
1530778686 08:18:06 elasticsearch green 1 1 0 0 0 0 0 0 - 100.0%  
root@smartThink-DTP:/home/vinayp/Desktop# curl [http://127.0.0.1:9201/\_cat/health?v](http://127.0.0.1:9201/_cat/health?v)  
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending\_tasks max\_task\_wait\_time active\_shards\_percent  
1530778692 08:18:12 elasticsearch green 1 1 0 0 0 0 0 0 - 100.0%

Any idea on how to proceed?

Regards,  
Vinayp

---

<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: [August 2, 2018, 8:36am UTC](https://discuss.elastic.co/t/running-2-node-elasticsearch-with-docker-compose-yml-file-on-a-single-machine/138668/2 "2018-08-02T08:36:22Z")

</div>

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