# Master not discovered or elected yet, after docker compose stop and start

**URL:** <https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [April 19, 2019, 5:59pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653 "2019-04-19T17:59:54Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![nufje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nufje/32/44284_2.png) [@nufje](https://discuss.elastic.co/u/nufje)\
**Post date:** [April 19, 2019, 5:59pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/1 "2019-04-19T17:59:54Z")

</div>

Hello,

Strange problem here (i think 🙂 )

I start elasticsearch on my laptop with docker-compose up -d es01, let the container start completly. Stop the containers with docker-compose stop. Then i do docker-compose up -d es01 again and elasticsearch gives me master not discovered or elected yet or when i check with

> curl [http://127.0.0.1:9200/\_cat/health](http://127.0.0.1:9200/_cat/health)

i get:

> {"error":{"root\_cause":[{"type":"master\_not\_discovered\_exception","reason":null}],"type":"master\_not\_discovered\_exception","reason":null},"status":503}

**When i stop the containers with docker=compose down -v**  
**The containers will start normally after that**

docker compose file is:

```
es01:
  image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
  container_name: es01
  volumes:
    - esdata01:/usr/share/elasticsearch/data
  environment:
  - node.name=es01
  - cluster.initial_master_nodes=es01,es02
  - cluster.name=docker-cluster
  - bootstrap.memory_lock=true
  - "ES_JAVA_OPTS=-Xms768m -Xmx768m"
  mem_limit: 1500m
  mem_reservation: 768m
  cpus: 0.70
  ulimits:
    memlock:
      soft: -1
      hard: -1
  ports:
    - "${ELASTICSEARCH_HOST_HTTP_PORT}:9200"
  depends_on:
    - es02
  # - php-fpm
  networks:
    - esnet

es02:
  image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
  container_name: es02
  environment:
    - node.name=es02
    - discovery.seed_hosts=es01
    - cluster.initial_master_nodes=es01,es02
    - cluster.name=docker-cluster
    - bootstrap.memory_lock=true
    - "ES_JAVA_OPTS=-Xms768m -Xmx768m"
  mem_limit: 1500m
  mem_reservation: 768m
  cpus: 0.70
  ulimits:
    memlock:
      soft: -1
      hard: -1
  volumes:
    - esdata02:/usr/share/elasticsearch/data
  networks:
      - esnet

  esnet:

  volumes:
       esdata01: local
       esdata02: local

```

---

<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:** [April 19, 2019, 6:57pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/2 "2019-04-19T18:57:40Z")

</div>

Can you share the Elasticsearch logs? Without them we can only speculate...

---

<div class="post-metadata">

**Author:** ![nufje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nufje/32/44284_2.png) [@nufje](https://discuss.elastic.co/u/nufje)\
**Post date:** [April 19, 2019, 7:15pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/3 "2019-04-19T19:15:54Z")

</div>

Hello,

You can see the log file [here](https://www.dropbox.com/s/9ngrrrude04woje/es.logs?dl=0), hopefully it is enough information for you.  
Best is you begin at the end of the file.

Thank you.

---

<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:** [April 19, 2019, 7:37pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/4 "2019-04-19T19:37:32Z")

</div>

Perfect, thanks.

```nohighlight
master not discovered or elected yet,
an election requires a node with id [alRw_LTeRqi8H9_0-0EAwg],
have discovered [] which is not a quorum;
discovery will continue using [127.0.0.1:9300, 127.0.0.1:9301, 127.0.0.1:9302, 127.0.0.1:9303, 127.0.0.1:9304]
from hosts providers and [{es01}{6VQf4azMRd-DqmZorZ357A}{yvhISyJ3TtSRPeK_mQjtZg}{172.19.0.3}{172.19.0.3:9300}{ml.machine_memory=1572864000, xpack.installed=true, ml.max_open_jobs=20}] from last-known cluster state; node term 1, last-accepted version 16 in term 1" 

```

This node is looking for another node with ID `alRw_LTeRqi8H9_0-0EAwg` to perform an election. Looking earlier in the logs I see that node `es02` has this ID. However this node can't find `es02` at any of the listed addresses.

---

<div class="post-metadata">

**Author:** ![nufje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nufje/32/44284_2.png) [@nufje](https://discuss.elastic.co/u/nufje)\
**Post date:** [April 19, 2019, 7:39pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/5 "2019-04-19T19:39:31Z")

</div>

Ok that is clear. But how can i solve this 🙂  
Because i will start and stop the containers a lot.

---

<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:** [April 19, 2019, 7:57pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/6 "2019-04-19T19:57:14Z")

</div>

> [@nufje](#):
>
> But how can i solve this

I'd suggest starting node `es02`.

It looks like you only have a two-node cluster, so you'll need to start both nodes before the cluster will form.

---

<div class="post-metadata">

**Author:** ![nufje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nufje/32/44284_2.png) [@nufje](https://discuss.elastic.co/u/nufje)\
**Post date:** [April 19, 2019, 8:10pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/7 "2019-04-19T20:10:56Z")

</div>

What i did is stopping both containers. Then i start

> docker-compose up -d es02

i let the container start and after that i start es01 with docker-compose. Same problem ☹

I shall provide logging of es02, maybe that is interesting for you.

[Logging es02](https://www.dropbox.com/s/z9ltposrbmv3jl2/es02.log?dl=0)

---

<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:** [April 19, 2019, 8:19pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/8 "2019-04-19T20:19:29Z")

</div>

Thanks, that's also useful. `es02` says this about its network configuration:

```nohighlight
publish_address {172.19.0.2:9300}, bound_addresses {0.0.0.0:9300}

```

However `es01` says this:

```nohighlight
discovery will continue using [127.0.0.1:9300, 127.0.0.1:9301, 127.0.0.1:9302, 127.0.0.1:9303, 127.0.0.1:9304]

```

It looks like `es01` isn't looking for `es02` in the right places. You need to make sure that each node knows how to find the other by setting [`discovery.seed_hosts`](https://www.elastic.co/guide/en/elasticsearch/reference/current/discovery-settings.html#unicast.hosts).

---

<div class="post-metadata">

**Author:** ![nufje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nufje/32/44284_2.png) [@nufje](https://discuss.elastic.co/u/nufje)\
**Post date:** [April 19, 2019, 8:34pm UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/9 "2019-04-19T20:34:48Z")

</div>

Thank you very much! Problem solved 🙂

---

<div class="post-metadata">

**Author:** ![THEjoezack](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thejoezack/32/40496_2.png) [@THEjoezack](https://discuss.elastic.co/u/THEjoezack)\
**Post date:** [April 20, 2019, 3:19am UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/10 "2019-04-20T03:19:08Z")

</div>

Just to make sure I understand the fix, you added an environment variable to es01 like:

- discovery.seed\_hosts=es02

I had the same problem, and doing this got things working again. If that is the right answer, than somebody should merge this change: PR: [https://github.com/elastic/elasticsearch/pull/41394](https://github.com/elastic/elasticsearch/pull/41394)

Documentation that's missing the discovery.seed:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html)

---

<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:** [April 20, 2019, 5:48am UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/11 "2019-04-20T05:48:21Z")

</div>

> [@THEjoezack](#):
>
> If that is the right answer, than somebody should merge this change

It is the right answer, yes. I didn't realise we were taking about the `docker-compose` file in the reference manual, but it does indeed look to be missing that. Thanks for pointing it out!

---

<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 18, 2019, 5:48am UTC](https://discuss.elastic.co/t/master-not-discovered-or-elected-yet-after-docker-compose-stop-and-start/177653/12 "2019-05-18T05:48:22Z")

</div>

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