# Three ES nodes in one VM with docker (works)

**URL:** <https://discuss.elastic.co/t/three-es-nodes-in-one-vm-with-docker-works/129665>\
**Category:** Elasticsearch\
**Created:** [April 26, 2018, 12:44pm UTC](https://discuss.elastic.co/t/three-es-nodes-in-one-vm-with-docker-works/129665 "2018-04-26T12:44:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheAnonymousModeIT](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@TheAnonymousModeIT](https://discuss.elastic.co/u/TheAnonymousModeIT)\
**Post date:** [April 26, 2018, 12:44pm UTC](https://discuss.elastic.co/t/three-es-nodes-in-one-vm-with-docker-works/129665/1 "2018-04-26T12:44:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![A\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_b/32/17104_2.png) [@A\_B](https://discuss.elastic.co/u/A_B)\
**Post date:** [April 27, 2018, 6:50am UTC](https://discuss.elastic.co/t/three-es-nodes-in-one-vm-with-docker-works/129665/2 "2018-04-27T06:50:47Z")

</div>

> [@TheAnonymousModeIT](#):
>
> - discovery.zen.ping.unicast.hosts=esdevnode1:9301,esdevnode1:9302

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

Use whatever the containers sees each other as...

---

<div class="post-metadata">

**Author:** ![TheAnonymousModeIT](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@TheAnonymousModeIT](https://discuss.elastic.co/u/TheAnonymousModeIT)\
**Post date:** [April 27, 2018, 8:12am UTC](https://discuss.elastic.co/t/three-es-nodes-in-one-vm-with-docker-works/129665/3 "2018-04-27T08:12:00Z")

</div>

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

---

<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:** [May 25, 2018, 8:12am UTC](https://discuss.elastic.co/t/three-es-nodes-in-one-vm-with-docker-works/129665/4 "2018-05-25T08:12:03Z")

</div>

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