Three ES nodes in one VM with docker (works)

Hello,

I would like to setup a development and learn environment.

One Virtual machine with linux and docker:

  • elastic search instance 1
  • elastic search instance 2
  • elastic search instance 3

EDIT: I had a typo in my initial docker-compose file. This is now the working one.

I created the following docker compose file:

version: '3'

services:

  zookeeper:
    container_name: dev_kafka_zookeeper
    image: 31z4/zookeeper:latest
    restart: always
    hostname: zookeeper
    ports:
     - 2181:2181

  # ************************************************************************** #

  kafka0:
    container_name: dev_kafka_node0
    image: reg.detss.corpintra.net/smartfactory/kafka:v1
    ports:
      - 9090:9091                                          # External Port / Internal Port  
    environment:
      ZOOKEEPER_IP: 172.17.0.1
      ZOOKEEPER_PORT: 2181
      KAFKA_BROOKER_ID: 0                                  # Unique Brooker ID
      KAFKA_LISTENERS_IP: localhost                        # Internal IP
      KAFKA_LISTENERS_PORT: 9091                           # Internal Port
      KAFKA_ADVERTISED_LISTENERS_IP: 192.168.194.134       # External IP
      KAFKA_ADVERTISED_LISTENERS_PORT: 9090                # Extenral Port
    depends_on:
     - zookeeper

  kafka1:
    container_name: dev_kafka_node1
    image: reg.detss.corpintra.net/smartfactory/kafka:v1
    ports:
      - 9091:9091
    environment:
      ZOOKEEPER_IP: 172.17.0.1
      ZOOKEEPER_PORT: 2181
      KAFKA_BROOKER_ID: 1
      KAFKA_LISTENERS_IP: localhost
      KAFKA_LISTENERS_PORT: 9091
      KAFKA_ADVERTISED_LISTENERS_IP: 192.168.194.134
      KAFKA_ADVERTISED_LISTENERS_PORT: 9091
    depends_on:
      - zookeeper

  kafka2:
    container_name: dev_kafka_node2
    image: reg.detss.corpintra.net/smartfactory/kafka:v1
    ports:
      - 9092:9091
    environment:
      ZOOKEEPER_IP: 172.17.0.1
      ZOOKEEPER_PORT: 2181
      KAFKA_BROOKER_ID: 2
      KAFKA_LISTENERS_IP: localhost
      KAFKA_LISTENERS_PORT: 9091
      KAFKA_ADVERTISED_LISTENERS_IP: 192.168.194.134
      KAFKA_ADVERTISED_LISTENERS_PORT: 9092
    depends_on:
      - zookeeper

  # ************************************************************************* #

  elasticsearch0:
    container_name: dev_es_node0
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    ports:
      - 9200:9200                                          # REST
      - 9300:9300                                          # Communication between nodes
    environment:
    - ES_JAVA_OPTS=-Xms512m -Xmx512m
    - cluster.name=devcluster
    - node.name=devnode0
    - node.master=true
    - node.data=true
    - discovery.zen.ping.unicast.hosts=dev_es_node0:9300,dev_es_node01:9301,dev_es_node02:9302
    volumes:
    - "esdata0:/usr/share/elasticsearch/data"

  elasticsearch1:
    container_name: dev_es_node01
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    ports:
      - 9201:9200                                          # REST
      - 9301:9300                                          # Communication between nodes
    environment:
    - ES_JAVA_OPTS=-Xms512m -Xmx512m
    - cluster.name=devcluster
    - node.name=devnode1
    - node.master=true
    - node.data=true
    - discovery.zen.ping.unicast.hosts=dev_es_node0:9300,dev_es_node01:9301,dev_es_node02:9302
    volumes:
    - "esdata1:/usr/share/elasticsearch/data"

  elasticsearch2:
    container_name: dev_es_node02
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    ports:
      - 9202:9200                                          # REST
      - 9302:9300                                          # Communication between nodes
    environment:
    - ES_JAVA_OPTS=-Xms512m -Xmx512m
    - cluster.name=devcluster
    - node.name=devnode2
    - node.master=true
    - node.data=true
    - discovery.zen.ping.unicast.hosts=dev_es_node0:9300,dev_es_node01:9301,dev_es_node02:9302
    volumes:
    - "esdata2:/usr/share/elasticsearch/data"

  # ************************************************************************* #
 
  kibana:
    container_name: dev_kafka_kibana
    image: docker.elastic.co/kibana/kibana:6.2.4
    ports:
      - 5601:5601                                          # Web Interface
    environment:
      ELASTICSEARCH_URL: http://192.168.194.134:9200

  # ************************************************************************* #
 
volumes:
  esdata0:
  esdata1:
  esdata2:

That should probably be

  • discovery.zen.ping.unicast.hosts=esdevnode0:9300,esdevnode1:9301,esdevnode2:9302

or

  • discovery.zen.ping.unicast.hosts=192.168.194.134:9300,192.168.194.134:9301,192.168.194.134:9302

I haven't used Docker much... :stuck_out_tongue:

Use whatever the containers sees each other as...

EDIT: I had a typo in my initial docker-compose file. I edited the initial post. It works now fine.

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