# Elastic Search with Docker

**URL:** <https://discuss.elastic.co/t/elastic-search-with-docker/245946>\
**Category:** Elasticsearch\
**Created:** [August 21, 2020, 6:13pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946 "2020-08-21T18:13:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nages](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nages/32/46943_2.png) [@nages](https://discuss.elastic.co/u/nages)\
**Post date:** [August 21, 2020, 6:13pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/1 "2020-08-21T18:13:59Z")

</div>

I ran the following docker compose script and I am expecting two nodes to be up, however this only one. There seems to be some obvious error , please suggest your inputs

Taken from the documentation [https://www.elastic.co/guide/en/elasticsearch/reference/6.8/docker.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/docker.html)

```
version: '2.2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.8.12
    container_name: elasticsearch
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - esnet
  elasticsearch2:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.8.12
    container_name: elasticsearch2
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata2:/usr/share/elasticsearch/data
    networks:
      - esnet

volumes:
  esdata1:
    driver: local
  esdata2:
    driver: local

networks:
  esnet:

```

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

`1598033352 18:09:12 docker-cluster green 1 1 0 0 0 0 0 0 - 100.0%`

docker-compose ps

```
Name Command State Ports              
------------------------------------------------------------------------------------------
elasticsearch /usr/local/bin/docker-entr ... Up 0.0.0.0:9200->9200/tcp, 9300/tcp
elasticsearch2 /usr/local/bin/docker-entr ... Up 9200/tcp, 9300/tcp
```

---

<div class="post-metadata">

**Author:** ![Emanuil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuil/32/36783_2.png) [@Emanuil](https://discuss.elastic.co/u/Emanuil)\
**Post date:** [August 21, 2020, 6:37pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/2 "2020-08-21T18:37:58Z")

</div>

Hmm, interesting. Did you wait long enough for them to find each other and form a cluster post boot-up? The docker-compose.yml you've pasted and the example one in the docs are exactly the same. When I run it, I get

```
1598034943 18:35:43 docker-cluster green 2 2 0 0 0 0 0 0 - 100.0%

```

i.e. 2 nodes of this exact version of Elasticsearch, exactly as it's supposed to work. I can't see an obvious reason why I can't reproduce it.

---

<div class="post-metadata">

**Author:** ![nages](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nages/32/46943_2.png) [@nages](https://discuss.elastic.co/u/nages)\
**Post date:** [August 21, 2020, 6:59pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/3 "2020-08-21T18:59:17Z")

</div>

hmm , no luck.  
when did you say "wait long enough" - how long do you mean ? 1 min ?

---

<div class="post-metadata">

**Author:** ![Emanuil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuil/32/36783_2.png) [@Emanuil](https://discuss.elastic.co/u/Emanuil)\
**Post date:** [August 21, 2020, 7:06pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/4 "2020-08-21T19:06:57Z")

</div>

Yeah, 1 min should be enough, but depends on your hardware. Usually it takes 20-30 seconds. I guess if it's not joined after 3 minutes you really have a problem. Here are my logs from the same example you're trying:

```auto
elasticsearch | [2020-08-21T18:34:18,866][INFO][o.e.c.s.MasterService] [DsbxDD4] zen-disco-node-join[{pfFjLH4}{pfFjLH4BTMulc2Mi6ilmPA}{mvCbPYD3SY2y_43qNIGYYw}{172.18.0.3}{172.18.0.3:9300}{ml.machine_memory=4129218560, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true}], reason: added {{pfFjLH4}{pfFjLH4BTMulc2Mi6ilmPA}{mvCbPYD3SY2y_43qNIGYYw}{172.18.0.3}{172.18.0.3:9300}{ml.machine_memory=4129218560, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true},}
elasticsearch2 | [2020-08-21T18:34:18,912][INFO][o.e.c.s.ClusterApplierService] [pfFjLH4] detected_master {DsbxDD4}{DsbxDD4lQ9-V7YVZ7RQ9kg}{h-TMjWdyRjGqRn_M9VMUfw}{172.18.0.2}{172.18.0.2:9300}{ml.machine_memory=4129218560, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true}, added {{DsbxDD4}{DsbxDD4lQ9-V7YVZ7RQ9kg}{h-TMjWdyRjGqRn_M9VMUfw}{172.18.0.2}{172.18.0.2:9300}{ml.machine_memory=4129218560, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true},}, reason: apply cluster state (from master [master {DsbxDD4}{DsbxDD4lQ9-V7YVZ7RQ9kg}{h-TMjWdyRjGqRn_M9VMUfw}{172.18.0.2}{172.18.0.2:9300}{ml.machine_memory=4129218560, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true} committed version [12]])
elasticsearch2 | [2020-08-21T18:34:18,971][WARN][o.e.x.s.a.s.m.NativeRoleMappingStore] [pfFjLH4] Failed to clear cache for realms [[]]
elasticsearch2 | [2020-08-21T18:34:18,975][INFO][o.e.x.s.a.TokenService] [pfFjLH4] refresh keys
elasticsearch2 | [2020-08-21T18:34:19,109][INFO][o.e.x.s.a.TokenService] [pfFjLH4] refreshed keys
elasticsearch | [2020-08-21T18:34:19,130][INFO][o.e.c.s.ClusterApplierService] [DsbxDD4] added {{pfFjLH4}{pfFjLH4BTMulc2Mi6ilmPA}{mvCbPYD3SY2y_43qNIGYYw}{172.18.0.3}{172.18.0.3:9300}{ml.machine_memory=4129218560, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true},}, reason: apply cluster state (from master [master {DsbxDD4}{DsbxDD4lQ9-V7YVZ7RQ9kg}{h-TMjWdyRjGqRn_M9VMUfw}{172.18.0.2}{172.18.0.2:9300}{ml.machine_memory=4129218560, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} committed version [12] source [zen-disco-node-join[{pfFjLH4}{pfFjLH4BTMulc2Mi6ilmPA}{mvCbPYD3SY2y_43qNIGYYw}{172.18.0.3}{172.18.0.3:9300}{ml.machine_memory=4129218560, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true}]]])
elasticsearch | [2020-08-21T18:34:19,141][WARN][o.e.d.z.ElectMasterService] [DsbxDD4] value for setting "discovery.zen.minimum_master_nodes" is too low. This can result in data loss! Please set it to at least a quorum of master-eligible nodes (current value: [-1], total number of master-eligible nodes used for publishing in this round: [2])
elasticsearch2 | [2020-08-21T18:34:19,160][INFO][o.e.h.n.Netty4HttpServerTransport] [pfFjLH4] publish_address {172.18.0.3:9200}, bound_addresses {0.0.0.0:9200}
elasticsearch2 | [2020-08-21T18:34:19,161][INFO][o.e.n.Node] [pfFjLH4] started
elasticsearch2 | [2020-08-21T18:34:19,267][INFO][o.e.l.LicenseService] [pfFjLH4] license [29417248-2d03-4cbd-a49e-4201736499da] mode [basic] - valid
elasticsearch2 | [2020-08-21T18:34:19,274][INFO][o.e.x.m.e.l.LocalExporter] [pfFjLH4] waiting for elected master node [{DsbxDD4}{DsbxDD4lQ9-V7YVZ7RQ9kg}{h-TMjWdyRjGqRn_M9VMUfw}{172.18.0.2}{172.18.0.2:9300}{ml.machine_memory=4129218560, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true}] to setup local exporter [default_local] (does it have x-pack installed?)
elasticsearch | [2020-08-21T18:34:19,321][INFO][o.e.l.LicenseService] [DsbxDD4] license [29417248-2d03-4cbd-a49e-4201736499da] mode [basic] - valid
elasticsearch2 | [2020-08-21T18:34:19,376][INFO][o.e.x.m.e.l.LocalExporter] [pfFjLH4] waiting for elected master node [{DsbxDD4}{DsbxDD4lQ9-V7YVZ7RQ9kg}{h-TMjWdyRjGqRn_M9VMUfw}{172.18.0.2}{172.18.0.2:9300}{ml.machine_memory=4129218560, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true}] to setup local exporter [default_local] (does it have x-pack installed?)

```

See especially `zen-disco-node-join` and `waiting for elected master` messages.

Try doing the `docker-compose up` startup and paste your entire log here, let's see what's going wrong. If it won't fit in a forum post, use [https://gist.github.com/](https://gist.github.com/) .

---

<div class="post-metadata">

**Author:** ![nages](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nages/32/46943_2.png) [@nages](https://discuss.elastic.co/u/nages)\
**Post date:** [August 21, 2020, 7:23pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/5 "2020-08-21T19:23:00Z")

</div>

> [@Emanuil](#):
>
> zen-disco

Here you go

> <https://gist.github.com/nag9s/5bf6f2f8d73672fc95b56aa07e845442>

I also happened to add one more service Elasticsearch service and kibana. Hope it should not be a problem

---

<div class="post-metadata">

**Author:** ![Emanuil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuil/32/36783_2.png) [@Emanuil](https://discuss.elastic.co/u/Emanuil)\
**Post date:** [August 21, 2020, 7:31pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/6 "2020-08-21T19:31:54Z")

</div>

What operating system and docker versions are you running this under? I'm curious since I wonder if something is interfering with the `esnet` docker network and the nodes are somehow not seeing each other.

---

<div class="post-metadata">

**Author:** ![nages](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nages/32/46943_2.png) [@nages](https://discuss.elastic.co/u/nages)\
**Post date:** [August 21, 2020, 7:34pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/7 "2020-08-21T19:34:32Z")

</div>

ubuntu  
i tool feel the same, it seems both are NOT aware of each other and creating their own clusters?

---

<div class="post-metadata">

**Author:** ![nages](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nages/32/46943_2.png) [@nages](https://discuss.elastic.co/u/nages)\
**Post date:** [August 21, 2020, 7:38pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/8 "2020-08-21T19:38:45Z")

</div>

hmm, this confirms that - both are trying to compete each other to become master nodes ?

` > elasticsearch2 |e[0m [2020-08-21T19:28:22,088][INFO][o.e.c.s.MasterService] [MJxcYj2] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {MJxcYj2}{MJxcYj2aQB2sVhBGDGQ7Pg}{Ejr7_xXSSa2LC-DHa5vHdg}{172.25.0.4}{172.25.0.4:9300}{ml.machine_memory=6115733504, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} > e[33melasticsearch2 |e[0m [2020-08-21T19:28:22,157][INFO][o.e.c.s.ClusterApplierService] [MJxcYj2] new_master {MJxcYj2}{MJxcYj2aQB2sVhBGDGQ7Pg}{Ejr7_xXSSa2LC-DHa5vHdg}{172.25.0.4}{172.25.0.4:9300}{ml.machine_memory=6115733504, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}, reason: apply cluster state (from master [master {MJxcYj2}{MJxcYj2aQB2sVhBGDGQ7Pg}{Ejr7_xXSSa2LC-DHa5vHdg}{172.25.0.4}{172.25.0.4:9300}{ml.machine_memory=6115733504, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]]) > elasticsearch |e[0m [2020-08-21T19:28:22,296][INFO][o.e.c.s.MasterService] [xwrHIvk] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {xwrHIvk}{xwrHIvkxRQmSnETYdQsWUQ}{Ull3Yz5HTOWwGeCOnOBApA}{172.25.0.3}{172.25.0.3:9300}{ml.machine_memory=6115733504, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} > e[36melasticsearch |e[0m [2020-08-21T19:28:22,367][INFO][o.e.c.s.ClusterApplierService] [xwrHIvk] new_master {xwrHIvk}{xwrHIvkxRQmSnETYdQsWUQ}{Ull3Yz5HTOWwGeCOnOBApA}{172.25.0.3}{172.25.0.3:9300}{ml.machine_memory=6115733504, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}, reason: apply cluster state (from master [master {xwrHIvk}{xwrHIvkxRQmSnETYdQsWUQ}{Ull3Yz5HTOWwGeCOnOBApA}{172.25.0.3}{172.25.0.3:9300}{ml.machine_memory=6115733504, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])`

---

<div class="post-metadata">

**Author:** ![nages](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nages/32/46943_2.png) [@nages](https://discuss.elastic.co/u/nages)\
**Post date:** [August 21, 2020, 8:43pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/9 "2020-08-21T20:43:04Z")

</div>

Ok, I found out the issue. It seems both the containers are _somehow_ not aware of each other and trying to create the clusters on their own.  
I introduced delay with "depends", it works fine now. Thanks

---

<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:** [September 18, 2020, 8:43pm UTC](https://discuss.elastic.co/t/elastic-search-with-docker/245946/10 "2020-09-18T20:43:28Z")

</div>

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