# Docker-compose with multi-node setup does not detect the second node

**URL:** https://discuss.elastic.co/t/docker-compose-with-multi-node-setup-does-not-detect-the-second-node/173685
**Category:** Elasticsearch
**Created:** [March 25, 2019, 8:11am UTC](https://discuss.elastic.co/t/docker-compose-with-multi-node-setup-does-not-detect-the-second-node/173685 "2019-03-25T08:11:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![blueren](https://avatars.discourse-cdn.com/v4/letter/b/ecae2f/32.png) [@blueren](https://discuss.elastic.co/u/blueren)
#### Post date: [March 25, 2019, 8:11am UTC](https://discuss.elastic.co/t/docker-compose-with-multi-node-setup-does-not-detect-the-second-node/173685/1 "2019-03-25T08:11:49Z")

</div>

I'm attempting to run two ES nodes from a single server. I'm trying to get an understanding of how replica sets etc work - specific to it helping out in terms of searching.

Currently I have some data on my first ES instance. I would like to create a second node and have it act as a replica set.

This is my current docker-compose (just the relevant part)

```
elasticsearch:
    image: elasticsearch-img:6.3.2
    container_name: elasticsearch-container
    volumes:
      - /data/elasticsearch-1/:/usr/share/elasticsearch/data
    ports: 
      - 9200:9200 #Elasticsearch HTTP
      - 9300:9300 #Elasticsearch TCP transport
    network_mode: bridge
    restart: always
    environment:
      - node.name=es-node-1
      - cluster.name=es-cluster
      - node.master=true
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms4g -Xmx4g"
    ulimits:
      nproc: 65535
      memlock:
        soft: -1
        hard: -1

  elasticsearch2:
    image: elasticsearch-img:6.3.2
    container_name: elasticsearch-container-2
    volumes:
      - /data/elasticsearch-2/:/usr/share/elasticsearch/data
    network_mode: bridge
    restart: always
    environment:
      - node.name=es-node-2
      - cluster.name=es-cluster
      - node.master=false
      - discovery.zen.ping.unicast.hosts=elasticsearch #for discovering the primary
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms4g -Xmx4g"
    ulimits:
      nproc: 65535
      memlock:
        soft: -1
        hard: -1

```

I referenced a few other help topics in this forum:

> [@Trying to setup elasticsearch cluster with docker-compose](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803):
>
> Hi, My environment is two physical machine, both running in docker-compose. I want to create elasticsearch cluster cross two docker container. here's my configure: ES1: IP: 10.251.34.60 docker-compose.yml: version: '2' services: elasticsearch: image: elasticsearch:5.4.2 hostname: es1 container\_name: es1 user: elasticsearch ports: - 9200:9200 - 9300:9300/udp environment: ES\_JAVA\_OPTS: "-Xms1g -Xmx1g" command: /usr/share/elasticsearch/bin/elastics…

> [@Can't see the second node whilst attempting to build a cluster](https://discuss.elastic.co/t/cant-see-the-second-node-whilst-attempting-to-build-a-cluster/163187):
>
> Hello, I am looking to add a second node and create a cluster. I have installed version 6.5.1 of Elasticsearch on 2 servers. The primary node has the full stack (Elasticsearch, Kibana, Logstash) and the second node has Elasticsearch installed. Primary node IP: 192.168.0.64 & Secondary node IP: 192.168.0.139 I have looked at the following questions: [Example](https://discuss.elastic.co/t/i-can-t-add-a-second-node-to-my-cluster/142223) and haven't been able to find a solution. There is currently no errors from the logs and everything should be working fine but via Kibana…

I brought up the instances. My es-node-1 comes up as usual. But my es-node-2 instance keeps erroring out stating the below.

```
[2019-03-25T08:03:33,759][WARN][o.e.d.z.ZenDiscovery] [es-node-2] not enough master nodes discovered during pinging (found [[]], but needed [-1]), pinging again
[2019-03-25T08:03:37,769][WARN][o.e.d.z.UnicastZenPing] [es-node-2] failed to resolve host [elasticsearch]
java.net.UnknownHostException: elasticsearch
	at java.net.InetAddress$CachedAddresses.get(InetAddress.java:793) ~[?:?]
	at java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:879) ~[?:?]
	at java.net.InetAddress.getAllByName0(InetAddress.java:1495) ~[?:?]
	at java.net.InetAddress.getAllByName(InetAddress.java:1354) ~[?:?]
	at java.net.InetAddress.getAllByName(InetAddress.java:1288) ~[?:?]
	at org.elasticsearch.transport.TcpTransport.parse(TcpTransport.java:933) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.transport.TcpTransport.addressesFromString(TcpTransport.java:888) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.transport.TransportService.addressesFromString(TransportService.java:710) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.discovery.zen.UnicastZenPing.lambda$resolveHostsLists$0(UnicastZenPing.java:212) ~[elasticsearch-6.3.2.jar:6.3.2]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:626) [elasticsearch-6.3.2.jar:6.3.2]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
	at java.lang.Thread.run(Thread.java:844) [?:?]

```

Kibana also still states that it sees only my es-node-1. es-node-2 is nowhere to be found. Where am I going wrong?

Thanks.

---

<div class="post-metadata">

### Author: ![blueren](https://avatars.discourse-cdn.com/v4/letter/b/ecae2f/32.png) [@blueren](https://discuss.elastic.co/u/blueren)
#### Post date: [March 25, 2019, 9:04am UTC](https://discuss.elastic.co/t/docker-compose-with-multi-node-setup-does-not-detect-the-second-node/173685/2 "2019-03-25T09:04:36Z")

</div>

> [@blueren](#):
>
> elasticsearch

I seem to have found my issue. It was because I did not add link to the es-node-2 container.

```
links:
   - elasticsearch

```

The above solved the issue for me.

---

<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: [April 22, 2019, 9:04am UTC](https://discuss.elastic.co/t/docker-compose-with-multi-node-setup-does-not-detect-the-second-node/173685/3 "2019-04-22T09:04:38Z")

</div>

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