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

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
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
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

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