# How to be connected to multiple master node on docker

**URL:** <https://discuss.elastic.co/t/how-to-be-connected-to-multiple-master-node-on-docker/151818>\
**Category:** Elasticsearch\
**Created:** [October 10, 2018, 10:30am UTC](https://discuss.elastic.co/t/how-to-be-connected-to-multiple-master-node-on-docker/151818 "2018-10-10T10:30:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loudone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loudone/32/33365_2.png) [@Loudone](https://discuss.elastic.co/u/Loudone)\
**Post date:** [October 10, 2018, 10:30am UTC](https://discuss.elastic.co/t/how-to-be-connected-to-multiple-master-node-on-docker/151818/1 "2018-10-10T10:30:34Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/e/ce5b61c7ffe24950e0b3594d704a48d3ecddce24.png)

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

---

<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:** [November 7, 2018, 10:32am UTC](https://discuss.elastic.co/t/how-to-be-connected-to-multiple-master-node-on-docker/151818/2 "2018-11-07T10:32:31Z")

</div>

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