# Run cluster in docker, on 2 hosts

**URL:** https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019
**Category:** Elasticsearch
**Tags:** docker
**Created:** [January 22, 2020, 9:31am UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019 "2020-01-22T09:31:19Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Nikolay\_Shalnev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolay_shalnev/32/44021_2.png) [@Nikolay\_Shalnev](https://discuss.elastic.co/u/Nikolay_Shalnev)
#### Post date: [January 22, 2020, 9:31am UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/1 "2020-01-22T09:31:19Z")

</div>

Hi.  
I have 2 hosts and 2 docker-compose file.

```
version: '3.6'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
    environment:
      - node.name=predprod-rumcelk1 / predprod-rumcelk0 for 2 hosts
      - cluster.name=good-cluster
      - "network.host=0.0.0.0"
      - discovery.zen.ping.unicast.hosts=["ip_one_host", "ip_two_host"]
      - "cluster.initial_master_nodes=predprod-rumcelk1,predprod-rumcelk0"
      - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
      - "path.repo=/opt/elasticsearch/snapshots"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    restart: "unless-stopped"
    ports:
      - 9200:9200
      - 9300:9300
    networks:
        elastic:
              ipv4_address: 10.5.0.6
networks:
  elastic:
        driver: bridge
        ipam:
          config:
            - subnet: 10.5.0.0/16

```

And i getting it in logs

> master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster, and this node must discover master-eligible nodes [predprod-rumcelk0, predprod-rumcelk1] to bootstrap a cluster: have discovered [{predprod-rumcelk0}{T4py-ijYRuWsP39mdIO6-Q}{JGzZOYMoQSm\_8Pigbd\_s1A}{10.5.0.6}{10.5.0.6:9300}{dilm}{ml.machine\_memory=3857117184, xpack.installed=true, ml.max\_open\_jobs=20}]; discovery will continue using [ip\_two\_host:9300, ip\_one\_host:9300] from hosts providers and [{predprod-rumcelk0}{T4py-ijYRuWsP39mdIO6-Q}{JGzZOYMoQSm\_8Pigbd\_s1A}{10.5.0.6}{10.5.0.6:9300}{dilm}{ml.machine\_memory=3857117184, xpack.installed=true, ml.max\_open\_jobs=20}] from last-known cluster state; node term 0, last-accepted version 0 in term 0

From the documentation: This message shows the node names `master-a.example.com` and `master-b.example.com` as well as the `cluster.initial_master_nodes` entries `master-a` and `master-b` , and it is clear from this message that they do not match exactly.

How to specify the names for the docker container?

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [January 22, 2020, 10:26am UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/2 "2020-01-22T10:26:11Z")

</div>

`this node must discover master-eligible nodes [predprod-rumcelk0, predprod-rumcelk1] to bootstrap a cluster: have discovered [{predprod-rumcelk0}{T4py-ijYRuWsP39mdIO6-Q}{JGzZOYMoQSm_8Pigbd_s1A}{10.5.0.6}{10.5.0.6:9300}{dilm}{ml.machine_memory=3857117184, xpack.installed=true, ml.max_open_jobs=20}]`

This node has discovered itself (!) but has not discovered the other node, so they cannot form a cluster. It is trying these addresses:

`discovery will continue using [ip_two_host:9300, ip_one_host:9300]`

Normally this is either that the other node isn't available at the expected address, or it's using the wrong internal address (does `10.5.0.6` look right to you?) or there's a firewall in the way which is blocking traffic. A good basic connectivity check from one host to another by logging into a host and doing `curl http://other_host:9300/`. If this returns `This is not an HTTP port` then connectivity is good; if you get anything else then you need to work on your network first.

---

<div class="post-metadata">

### Author: ![Nikolay\_Shalnev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolay_shalnev/32/44021_2.png) [@Nikolay\_Shalnev](https://discuss.elastic.co/u/Nikolay_Shalnev)
#### Post date: [January 22, 2020, 10:38am UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/3 "2020-01-22T10:38:08Z")

</div>

Yes, connectivity is good.  
ip\_two\_host:9300 = host ip -\> 10.5.0.6 = docker conteiner ip ( in docker network ).

if you get curl inside the container:

root@predprod-rumcelk1:/srv/docker-compose# docker exec -it docker-compose\_elasticsearch\_1 bash  
[root@b04756549ac5 elasticsearch]# curl http://ip\_one\_host:9200/  
{  
"name" : "predprod-rumcelk0",  
"cluster\_name" : "good-cluster",  
"cluster\_uuid" : "_na_",  
"version" : {  
"number" : "7.5.1",  
"build\_flavor" : "default",  
"build\_type" : "docker",  
"build\_hash" : "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96",  
"build\_date" : "2019-12-16T22:57:37.835892Z",  
"build\_snapshot" : false,  
"lucene\_version" : "8.3.0",  
"minimum\_wire\_compatibility\_version" : "6.8.0",  
"minimum\_index\_compatibility\_version" : "6.0.0-beta1"  
},  
"tagline" : "You Know, for Search"  
}  
[root@b04756549ac5 elasticsearch]# curl http://ip\_two\_host:9200/  
{  
"name" : "predprod-rumcelk1",  
"cluster\_name" : "good-cluster",  
"cluster\_uuid" : "_na_",  
"version" : {  
"number" : "7.5.1",  
"build\_flavor" : "default",  
"build\_type" : "docker",  
"build\_hash" : "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96",  
"build\_date" : "2019-12-16T22:57:37.835892Z",  
"build\_snapshot" : false,  
"lucene\_version" : "8.3.0",  
"minimum\_wire\_compatibility\_version" : "6.8.0",  
"minimum\_index\_compatibility\_version" : "6.0.0-beta1"  
},  
"tagline" : "You Know, for Search"  
}

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [January 22, 2020, 10:40am UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/4 "2020-01-22T10:40:38Z")

</div>

That's not quite what I said. You need to check connectivity for port 9300, not 9200, and you need to see the response `This is not an HTTP port`.

---

<div class="post-metadata">

### Author: ![Nikolay\_Shalnev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolay_shalnev/32/44021_2.png) [@Nikolay\_Shalnev](https://discuss.elastic.co/u/Nikolay_Shalnev)
#### Post date: [January 22, 2020, 10:43am UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/5 "2020-01-22T10:43:47Z")

</div>

Yes, it is wokr..  
Did not apply  
root@predprod-rumcelk1:~# curl [http://10.10.119.171:9300/](http://10.10.119.171:9300/)  
This is not an HTTP port  
root@predprod-rumcelk0:~# curl [http://10.10.119.172:9300/](http://10.10.119.172:9300/)  
This is not an HTTP port

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [January 22, 2020, 10:49am UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/6 "2020-01-22T10:49:02Z")

</div>

These addresses are different from the ones the nodes are using to talk to each other. The nodes are trying to communicate on addresses like `10.5.0.6`, not `10.10.119.171`.

---

<div class="post-metadata">

### Author: ![Nikolay\_Shalnev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolay_shalnev/32/44021_2.png) [@Nikolay\_Shalnev](https://discuss.elastic.co/u/Nikolay_Shalnev)
#### Post date: [January 22, 2020, 10:52am UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/7 "2020-01-22T10:52:45Z")

</div>

10.10.119.171 this is the host address  
What to do to use it

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [January 22, 2020, 11:04am UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/8 "2020-01-22T11:04:31Z")

</div>

I'm not a Docker networking expert, but it looks like a `bridge` network is the wrong choice for your setup. From [these docs](https://docs.docker.com/network/bridge/):

> Bridge networks apply to containers running on the **same** Docker daemon host. For communication among containers running on different Docker daemon hosts, you can either manage routing at the OS level, or you can use an [overlay network](https://docs.docker.com/network/overlay/).

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [January 22, 2020, 12:43pm UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/9 "2020-01-22T12:43:55Z")

</div>

FWIW I set up a cluster in this state to see how easy it is to diagnose and discovered that we don't really log anything helpful if your config is like this, so I opened [https://github.com/elastic/elasticsearch/pull/51304](https://github.com/elastic/elasticsearch/pull/51304).

---

<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: [February 19, 2020, 12:44pm UTC](https://discuss.elastic.co/t/run-cluster-in-docker-on-2-hosts/216019/10 "2020-02-19T12:44:01Z")

</div>

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