How to be connected to multiple master node on docker

Dear all,

I'm currently trying to configure a elasticsearch cluster with 2 masters and 2 data nodes under docker-compose

Please find below my docker-compose

version: '2.2'
services:
  master1:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.4.2
    container_name: esmaster1
    environment:
      - xpack.security.enabled=false
      - xpack.monitoring.enabled=false
      - xpack.ml.enabled=false
      - xpack.graph.enabled=false
      - xpack.watcher.enabled=false
      - cluster.name=es_cluster
      - bootstrap.memory_lock=true
      - http.cors.enabled=true
      - "http.cors.allow-origin=*"
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=esmaster1,esmaster2"
      - "node.master=true"
      - "node.data=true"
    ulimits:
      nproc: 65535
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata1:/usr/share/elasticsearch/data

  master2:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.4.2
    container_name: esmaster2
    environment:
      - xpack.security.enabled=false
      - xpack.monitoring.enabled=false
      - xpack.ml.enabled=false
      - xpack.graph.enabled=false
      - xpack.watcher.enabled=false
      - cluster.name=es_cluster
      - bootstrap.memory_lock=true
      - http.cors.enabled=true
      - "http.cors.allow-origin=*"
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=esmaster1,esmaster2"
      - "node.master=true"
      - "node.data=true"
    ulimits:
      nproc: 65535
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata2:/usr/share/elasticsearch/data

  elasticsearch1:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.4.2
    container_name: elasticsearch1
    environment:
      - xpack.security.enabled=false
      - xpack.monitoring.enabled=false
      - xpack.ml.enabled=false
      - xpack.graph.enabled=false
      - xpack.watcher.enabled=false
      - cluster.name=es_cluster
      - bootstrap.memory_lock=true
      - http.cors.enabled=true
      - "http.cors.allow-origin=*"
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=esmaster1,esmaster2"
      - "node.master=false"
      - "node.data=true"
    ulimits:
      nproc: 65535
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata3:/usr/share/elasticsearch/data

  elasticsearch2:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.4.2
    container_name: elasticsearch2
    environment:
      - xpack.security.enabled=false
      - xpack.monitoring.enabled=false
      - xpack.ml.enabled=false
      - xpack.graph.enabled=false
      - xpack.watcher.enabled=false
      - cluster.name=es_cluster
      - bootstrap.memory_lock=true
      - http.cors.enabled=true
      - "http.cors.allow-origin=*"
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=esmaster1,esmaster2"
      - "node.master=false"
      - "node.data=true"
    ulimits:
      nproc: 65535
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata4:/usr/share/elasticsearch/data

volumes:
  esdata1:
    driver: local
  esdata2:
    driver: local
  esdata3:
    driver: local
  esdata4:
    driver: local

My cluster is working fine, and I'm able to be connected to both masters on the host with the publish_address

But, I'm not able to be connected outside my VM, because my both master is listenning on the same port 9200.

Does anyone know the solution to be connected on the differents master publish_address outside my VM?

Thank you for help

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