# Trying to setup elasticsearch cluster with docker-compose

**URL:** <https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803>\
**Category:** Elasticsearch\
**Created:** [November 8, 2017, 5:55am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803 "2017-11-08T05:55:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hanase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanase/32/40115_2.png) [@hanase](https://discuss.elastic.co/u/hanase)\
**Post date:** [November 8, 2017, 5:55am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/1 "2017-11-08T05:55:10Z")

</div>

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/elasticsearch

```

elasticsearch.yml:

```
http.host: 0.0.0.0
transport.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1

cluster.name: prod_es_cluster
node.name: prod_es_node1
node.master: true
node.data: true
discovery.zen.ping_timeout: 10s

network.host: 0.0.0.0
network.bind_host: 0.0.0.0
network.publish_host: 0.0.0.0
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["10.251.34.50:9300","10.251.34.60:9300"]

```

ES2:  
IP: 10.251.34.50

```
docker-compose.yml:

version: '2'
services:
  elasticsearch:
    image: elasticsearch:5.4.2
    hostname: es2
    container_name: es2
    user: elasticsearch
    ports:
    - 9200:9200
    - 9300:9300/udp
    environment:
      ES_JAVA_OPTS: "-Xms1g -Xmx1g"
    command: /usr/share/elasticsearch/bin/elasticsearch

```

elasticsearch.yml:

```
http.host: 0.0.0.0
transport.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1

cluster.name: prod_es_cluster
node.name: prod_es_node2
node.master: true
node.data: true
discovery.zen.ping_timeout: 10s

network.host: 0.0.0.0
network.bind_host: 0.0.0.0
network.publish_host: 0.0.0.0
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["10.251.34.50:9300","10.251.34.60:9300"]

```

how to setup cluster with docker container, any ideas?

Thanks! 😀

---

<div class="post-metadata">

**Author:** ![hanase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanase/32/40115_2.png) [@hanase](https://discuss.elastic.co/u/hanase)\
**Post date:** [November 8, 2017, 5:56am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/2 "2017-11-08T05:56:14Z")

</div>

And here is logs, it seems like not connect each other

```
ES1: 

```

[2017-11-08T03:15:54,666][INFO][o.e.n.Node] [prod\_es\_node1] initializing ...  
[2017-11-08T03:15:54,734][INFO][o.e.e.NodeEnvironment] [prod\_es\_node1] using [1] data paths, mounts [[/ (rootfs)]], net usable\_space [9.  
6gb], net total\_space [9.9gb], spins? [unknown], types [rootfs]  
[2017-11-08T03:15:54,734][INFO][o.e.e.NodeEnvironment] [prod\_es\_node1] heap size [990.7mb], compressed ordinary object pointers [true]  
[2017-11-08T03:15:54,736][INFO][o.e.n.Node] [prod\_es\_node1] node name [prod\_es\_node1], node ID [e7k9AdUIQkeCWIRifMOW9w]  
[2017-11-08T03:15:54,736][INFO][o.e.n.Node] [prod\_es\_node1] version[5.4.2], pid[1], build[929b078/2017-06-15T02:29:28.122Z],  
OS[Linux/3.10.0-327.el7.x86\_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0\_131/25.131-b11]  
[2017-11-08T03:15:54,736][INFO][o.e.n.Node] [prod\_es\_node1] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSIn  
itiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+DisableExplicitGC, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=tr  
ue, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimiza  
tion=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true,  
-XX:+HeapDumpOnOutOfMemoryError, -Xms1g, -Xmx1g, -Des.path.home=/usr/share/elasticsearch]  
[2017-11-08T03:15:55,542][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [aggs-matrix-stats]  
[2017-11-08T03:15:55,542][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [ingest-common]  
[2017-11-08T03:15:55,542][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [lang-expression]  
[2017-11-08T03:15:55,542][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [lang-groovy]  
[2017-11-08T03:15:55,542][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [lang-mustache]  
[2017-11-08T03:15:55,542][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [lang-painless]  
[2017-11-08T03:15:55,542][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [percolator]  
[2017-11-08T03:15:55,542][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [reindex]  
[2017-11-08T03:15:55,543][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [transport-netty3]  
[2017-11-08T03:15:55,543][INFO][o.e.p.PluginsService] [prod\_es\_node1] loaded module [transport-netty4]  
[2017-11-08T03:15:55,543][INFO][o.e.p.PluginsService] [prod\_es\_node1] no plugins loaded  
[2017-11-08T03:15:56,851][INFO][o.e.d.DiscoveryModule] [prod\_es\_node1] using discovery type [zen]  
[2017-11-08T03:15:57,289][INFO][o.e.n.Node] [prod\_es\_node1] initialized  
[2017-11-08T03:15:57,289][INFO][o.e.n.Node] [prod\_es\_node1] starting ...  
[2017-11-08T03:15:57,419][INFO][o.e.t.TransportService] [prod\_es\_node1] publish\_address {172.24.0.2:9300}, bound\_addresses {[::]:9300}  
[2017-11-08T03:15:57,425][INFO][o.e.b.BootstrapChecks] [prod\_es\_node1] bound or publishing to a non-loopback or non-link-local address,  
enforcing bootstrap checks  
[2017-11-08T03:16:07,490][INFO][o.e.c.s.ClusterService] [prod\_es\_node1] new\_master {prod\_es\_node1}{e7k9AdUIQkeCWIRifMOW9w}{ja48giATT-m8HN  
kUEDdBzQ}{172.24.0.2}{172.24.0.2:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)  
[2017-11-08T03:16:07,507][INFO][o.e.h.n.Netty4HttpServerTransport] [prod\_es\_node1] publish\_address {172.24.0.2:9200}, bound\_addresses {[::]:  
9200}  
[2017-11-08T03:16:07,510][INFO][o.e.n.Node] [prod\_es\_node1] started  
[2017-11-08T03:16:07,514][INFO][o.e.g.GatewayService] [prod\_es\_node1] recovered [0] indices into cluster\_state

---

<div class="post-metadata">

**Author:** ![hanase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanase/32/40115_2.png) [@hanase](https://discuss.elastic.co/u/hanase)\
**Post date:** [November 8, 2017, 5:57am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/3 "2017-11-08T05:57:39Z")

</div>

```
ES2:

```

[2017-11-08T03:16:25,279][INFO][o.e.n.Node] [prod\_es\_node2] initializing ...  
[2017-11-08T03:16:25,345][INFO][o.e.e.NodeEnvironment] [prod\_es\_node2] using [1] data paths, mounts [[/ (rootfs)]], net usable\_space [9.  
6gb], net total\_space [9.9gb], spins? [unknown], types [rootfs]  
[2017-11-08T03:16:25,345][INFO][o.e.e.NodeEnvironment] [prod\_es\_node2] heap size [990.7mb], compressed ordinary object pointers [true]  
[2017-11-08T03:16:25,346][INFO][o.e.n.Node] [prod\_es\_node2] node name [prod\_es\_node2], node ID [KpS2TUq7Q5m2k1sONaD5zQ]  
[2017-11-08T03:16:25,346][INFO][o.e.n.Node] [prod\_es\_node2] version[5.4.2], pid[1], build[929b078/2017-06-15T02:29:28.122Z],  
OS[Linux/3.10.0-327.4.4.el7.x86\_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0\_131/25.131-b11]  
[2017-11-08T03:16:25,346][INFO][o.e.n.Node] [prod\_es\_node2] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSIn  
itiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+DisableExplicitGC, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=tr  
ue, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimiza  
tion=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true,  
-XX:+HeapDumpOnOutOfMemoryError, -Xms1g, -Xmx1g, -Des.path.home=/usr/share/elasticsearch]  
[2017-11-08T03:16:26,100][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [aggs-matrix-stats]  
[2017-11-08T03:16:26,100][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [ingest-common]  
[2017-11-08T03:16:26,100][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [lang-expression]  
[2017-11-08T03:16:26,100][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [lang-groovy]  
[2017-11-08T03:16:26,101][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [lang-mustache]  
[2017-11-08T03:16:26,101][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [lang-painless]  
[2017-11-08T03:16:26,101][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [percolator]  
[2017-11-08T03:16:26,101][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [reindex]  
[2017-11-08T03:16:26,101][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [transport-netty3]  
[2017-11-08T03:16:26,101][INFO][o.e.p.PluginsService] [prod\_es\_node2] loaded module [transport-netty4]  
[2017-11-08T03:16:26,101][INFO][o.e.p.PluginsService] [prod\_es\_node2] no plugins loaded  
[2017-11-08T03:16:27,379][INFO][o.e.d.DiscoveryModule] [prod\_es\_node2] using discovery type [zen]  
[2017-11-08T03:16:27,811][INFO][o.e.n.Node] [prod\_es\_node2] initialized  
[2017-11-08T03:16:27,811][INFO][o.e.n.Node] [prod\_es\_node2] starting ...  
[2017-11-08T03:16:27,940][INFO][o.e.t.TransportService] [prod\_es\_node2] publish\_address {172.21.0.2:9300}, bound\_addresses {[::]:9300}  
[2017-11-08T03:16:27,946][INFO][o.e.b.BootstrapChecks] [prod\_es\_node2] bound or publishing to a non-loopback or non-link-local address,  
enforcing bootstrap checks  
[2017-11-08T03:16:37,986][INFO][o.e.c.s.ClusterService] [prod\_es\_node2] new\_master {prod\_es\_node2}{KpS2TUq7Q5m2k1sONaD5zQ}{RtjqOsnjTlSvg4  
sjqoJWJQ}{172.21.0.2}{172.21.0.2:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)  
[2017-11-08T03:16:38,006][INFO][o.e.h.n.Netty4HttpServerTransport] [prod\_es\_node2] publish\_address {172.21.0.2:9200}, bound\_addresses {[::]:  
9200}  
[2017-11-08T03:16:38,009][INFO][o.e.n.Node] [prod\_es\_node2] started  
[2017-11-08T03:16:38,016][INFO][o.e.g.GatewayService] [prod\_es\_node2] recovered [0] indices into cluster\_state

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 8, 2017, 7:12am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/4 "2017-11-08T07:12:11Z")

</div>

Does [https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-prod-cluster-composefile](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-prod-cluster-composefile) help?

---

<div class="post-metadata">

**Author:** ![hanase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanase/32/40115_2.png) [@hanase](https://discuss.elastic.co/u/hanase)\
**Post date:** [November 9, 2017, 2:00am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/5 "2017-11-09T02:00:29Z")

</div>

Hi warkolm,

The example looks like in same physical machine, running one docker compose file and create two container.

Networking should be fine.

But in my case, like this

 ![cluster](https://us1.discourse-cdn.com/elastic/original/3X/1/1/119e566696e48b20ca0c9bb5e9afb919b0f20a19.png)

How to configure the networking, that elasticsearch cluster can be connected each other.

Thank you 😃

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 9, 2017, 2:20am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/6 "2017-11-09T02:20:24Z")

</div>

Ok, let's look at docker-compose.yml:

```auto
version: '2'
services:
  elasticsearch:
    image: elasticsearch:5.4.2
    hostname: es2
    container_name: es2
    user: elasticsearch
    ports:
    - 9200:9200
    - 9300:9300/udp
    environment:
      ES_JAVA_OPTS: "-Xms1g -Xmx1g"
    command: /usr/share/elasticsearch/bin/elasticsearch

```

The main problem with this is `- 9300:9300/udp`. Elasticsearch discovery uses TCP and you are only allowing UDP. Removed `/udp` and you should get everything working.

A few other tips for your `elasticsearch.yml`, all you need is:

```auto
cluster.name: prod_es_cluster
node.name: prod_es_node2
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["10.251.34.50","10.251.34.60"]

```

Everything else you have defined is the defaults, so you don't need to provide them.

Also `discovery.zen.minimum_master_nodes: 1` is bad, see [https://www.elastic.co/guide/en/elasticsearch/guide/2.x/important-configuration-changes.html#\_minimum\_master\_nodes](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/important-configuration-changes.html#_minimum_master_nodes)

Finally, you should 100% be using our docker image here - [https://github.com/elastic/elasticsearch-docker](https://github.com/elastic/elasticsearch-docker). We keep it up to date and apply evolving best practises 🙂

---

<div class="post-metadata">

**Author:** ![hanase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanase/32/40115_2.png) [@hanase](https://discuss.elastic.co/u/hanase)\
**Post date:** [November 9, 2017, 4:10am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/7 "2017-11-09T04:10:48Z")

</div>

Hi warkolm,

Now I removed `/udp` config.

docker image is using elasticsearch:5.4.2 but export from other testing docker machine, then import this server

so named es:542

docker-compose.yml like this

```
version: '2'

services:
  elasticsearch:
	image: es:542
    hostname: es2
    container_name: es2
    user: elasticsearch
    ports:
    - 9200:9200
    - 9300:9300
    command: /usr/share/elasticsearch/bin/elasticsearch
    environment:
    - ES_JAVA_OPTS=-Xms1g -Xmx1g

```

change `elasticsearch.yml` like this `discovery.zen.minimum_master_nodes: 2`

```
http.host: 0.0.0.0
transport.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 2

cluster.name: prod_es_cluster
node.name: prod_es_node1
node.master: true
node.data: true
discovery.zen.ping_timeout: 10s

network.host: 0.0.0.0
network.bind_host: 0.0.0.0
network.publish_host: 0.0.0.0
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["127.0.0.1", "[::1]"]

```

and the log:

[2017-11-09T03:49:09,261][INFO][o.e.t.TransportService] [prod\_es\_node1] publish\_address {172.24.0.2:9300}, bound\_addresses {[::]:9300}  
[2017-11-09T03:49:09,270][INFO][o.e.b.BootstrapChecks] [prod\_es\_node1] bound or publishing to a non-loopback or non-link-local address,e  
nforcing bootstrap checks  
[2017-11-09T03:49:19,319][WARN][o.e.d.z.ZenDiscovery] [prod\_es\_node1] not enough master nodes discovered during pinging (found [[Candid  
ate{node={prod\_es\_node1}{BxKzhOnJTUC50cYTz\_HmfA}{nISnloDKQBul5sVdPd5m\_Q}{172.24.0.2}{172.24.0.2:9300}, clusterStateVersion=-1}]], but needed[  
2]), pinging again  
[2017-11-09T03:49:29,321][WARN][o.e.d.z.ZenDiscovery] [prod\_es\_node1] not enough master nodes discovered during pinging (found [[Candid  
ate{node={prod\_es\_node1}{BxKzhOnJTUC50cYTz\_HmfA}{nISnloDKQBul5sVdPd5m\_Q}{172.24.0.2}{172.24.0.2:9300}, clusterStateVersion=-1}]], but needed[  
2]), pinging again  
[2017-11-09T03:49:39,297][WARN][o.e.n.Node] [prod\_es\_node1] timed out while waiting for initial discovery state - timeout: 30  
s  
[2017-11-09T03:49:39,307][INFO][o.e.h.n.Netty4HttpServerTransport] [prod\_es\_node1] publish\_address {172.24.0.2:9200}, bound\_addresses {[::]:  
9200}  
[2017-11-09T03:49:39,310][INFO][o.e.n.Node] [prod\_es\_node1] started  
[2017-11-09T03:49:39,323][WARN][o.e.d.z.ZenDiscovery] [prod\_es\_node1] not enough master nodes discovered during pinging (found [[Candid  
ate{node={prod\_es\_node1}{BxKzhOnJTUC50cYTz\_HmfA}{nISnloDKQBul5sVdPd5m\_Q}{172.24.0.2}{172.24.0.2:9300}, clusterStateVersion=-1}]], but needed[  
2]), pinging again

it still doesn't connected each other 😥

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 9, 2017, 4:33am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/8 "2017-11-09T04:33:18Z")

</div>

> [@hanase](#):
>
> discovery.zen.ping.unicast.hosts: ["127.0.0.1", "[::1]"]

That's only ever going to connect to itself.

---

<div class="post-metadata">

**Author:** ![hanase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanase/32/40115_2.png) [@hanase](https://discuss.elastic.co/u/hanase)\
**Post date:** [November 9, 2017, 10:00am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/9 "2017-11-09T10:00:38Z")

</div>

now `elasticsearh.yml` is

```
http.host: 0.0.0.0
transport.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 2

cluster.name: prod_es_cluster
node.name: prod_es_node1
node.master: true
node.data: true
discovery.zen.ping_timeout: 10s

network.host: 0.0.0.0
network.bind_host: 0.0.0.0
network.publish_host: 0.0.0.0
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["10.251.34.50","10.251.34.60"]

```

and logs

`ES1`

[2017-11-09T05:56:10,552][INFO][o.e.t.TransportService] `[prod_es_node1] publish_address {172.24.0.2:9300}, bound_addresses {[::]:9300}`  
[2017-11-09T05:56:10,558][INFO][o.e.b.BootstrapChecks] [prod\_es\_node1] bound or publishing to a non-loopback or non-link-local address,enforcing bootstrap checks  
[2017-11-09T05:56:40,576][WARN][o.e.n.Node]`[prod_es_node1] timed out while waiting for initial discovery state - timeout: 30s`  
[2017-11-09T05:56:40,584][INFO][o.e.h.n.Netty4HttpServerTransport] [prod\_es\_node1] publish\_address {172.24.0.2:9200}, bound\_addresses {[::]:9200}  
[2017-11-09T05:56:40,587][INFO][o.e.n.Node] [prod\_es\_node1] started

`ES2`

[2017-11-09T09:37:20,084][WARN][o.e.d.z.ZenDiscovery] [prod\_es\_node2]`failed to connect to master [{prod_es_node1}{BxKzhOnJTUC50cYTz_Hm fA}{zqtU07jfQJOrmB9AYL01Ig}{172.24.0.2}{172.24.0.2:9300}], retrying...`  
org.elasticsearch.transport.ConnectTransportException:`[prod_es_node1][172.24.0.2:9300] connect_timeout[30s]`  
at org.elasticsearch.transport.netty4.Netty4Transport.connectToChannels(Netty4Transport.java:361) ~[?:?]  
at org.elasticsearch.transport.TcpTransport.openConnection(TcpTransport.java:549) ~[elasticsearch-5.4.2.jar:5.4.2]  
at org.elasticsearch.transport.TcpTransport.connectToNode(TcpTransport.java:473) ~[elasticsearch-5.4.2.jar:5.4.2]  
at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:315) ~[elasticsearch-5.4.2.jar:5.4.2]  
at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:302) ~[elasticsearch-5.4.2.jar:5.4.2]  
at org.elasticsearch.discovery.zen.ZenDiscovery.joinElectedMaster(ZenDiscovery.java:468) [elasticsearch-5.4.2.jar:5.4.2]  
at org.elasticsearch.discovery.zen.ZenDiscovery.innerJoinCluster(ZenDiscovery.java:420) [elasticsearch-5.4.2.jar:5.4.2]  
at org.elasticsearch.discovery.zen.ZenDiscovery.access$4100(ZenDiscovery.java:83) [elasticsearch-5.4.2.jar:5.4.2]  
at org.elasticsearch.discovery.zen.ZenDiscovery$JoinThreadControl$1.run(ZenDiscovery.java:1197) [elasticsearch-5.4.2.jar:5.4.2]  
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:569) [elasticsearch-5.4.2.  
jar:5.4.2]  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0\_131]  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0\_131]  
at java.lang.Thread.run(Thread.java:748) [?:1.8.0\_131]  
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException:`Connection refused: 172.24.0.2/172.24.0.2:9300`  
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[?:?]

---

<div class="post-metadata">

**Author:** ![hanase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanase/32/40115_2.png) [@hanase](https://discuss.elastic.co/u/hanase)\
**Post date:** [November 17, 2017, 2:32am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/10 "2017-11-17T02:32:05Z")

</div>

Now I use `openvswitch` and `pipework` to build cluster network

ovs setting:

```
#ES1
sudo brctl addbr br0
sudo ip link set dev br0 up
sudo ovs-vsctl add-br ovs0
sudo ovs-vsctl set bridge ovs0 stp_enable=true
sudo ovs-vsctl add-port ovs0 br0
sudo ovs-vsctl add-port ovs0 gre0 -- set interface gre0 type=gre options:remote_ip=10.251.34.50

```

pipwork setting:

```
sudo pipework-master/pipework br0 -i eth1 es1 172.28.0.2/8

```

docker container network information:

elasticsearch@es1:/usr/share/elasticsearch$ ip a

521: eth1@if522: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 1500 qdisc pfifo\_fast state UP group default qlen 1000  
link/ether 4e:06:91:91:1f:3e brd ff:ff:ff:ff:ff:ff  
inet 172.28.0.2/8 brd 172.255.255.255 scope global eth1  
valid\_lft forever preferred\_lft forever

after setting both two docker container, cluster should be work !!

# ES1

elasticsearch@es1:/usr/share/elasticsearch$ ping 172.18.0.2  
PING 172.18.0.2 (172.18.0.2): 56 data bytes  
64 bytes from 172.18.0.2: icmp\_seq=0 ttl=64 time=1.222 ms  
64 bytes from 172.18.0.2: icmp\_seq=1 ttl=64 time=0.339 ms  
64 bytes from 172.18.0.2: icmp\_seq=2 ttl=64 time=0.547 ms  
64 bytes from 172.18.0.2: icmp\_seq=3 ttl=64 time=0.303 ms  
64 bytes from 172.18.0.2: icmp\_seq=4 ttl=64 time=0.333 ms  
64 bytes from 172.18.0.2: icmp\_seq=5 ttl=64 time=0.362 ms

#ES logs:  
[2017-11-17T02:06:21,205][INFO][o.e.n.Node] [prod\_es\_node1] started  
[2017-11-17T02:06:21,223][INFO][o.e.c.s.ClusterService] [prod\_es\_node1] new\_master {prod\_es\_node1}{IoG7C5BYQ26AYsggMuJo2A}{AL3oD0itR1CgibIr-x-8Sg}{172.28.0.2}{172.28.0.2:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)  
[2017-11-17T02:06:21,254][INFO][o.e.g.GatewayService] [prod\_es\_node1] recovered [0] indices into cluster\_state  
[2017-11-17T02:06:29,205][INFO][o.e.c.s.ClusterService] [prod\_es\_node1] added {{prod\_es\_node2}{ZA7CwKyBQS2gm-OamVSz2g}{U6WQyzwoQCiDkwBvmUxoQw}{172.18.0.2}{172.18.0.2:9300},}, reason: zen-disco-node-join[{prod\_es\_node2}{ZA7CwKyBQS2gm-OamVSz2g}{U6WQyzwoQCiDkwBvmUxoQw}{172.18.0.2}{172.18.0.2:9300}]

curl localhost:9200/\_cluster/health?pretty  
{  
"cluster\_name" : "prod\_es\_cluster",  
"status" : "green",  
"timed\_out" : false,  
"number\_of\_nodes" : 2,  
"number\_of\_data\_nodes" : 2,  
"active\_primary\_shards" : 0,  
"active\_shards" : 0,  
"relocating\_shards" : 0,  
"initializing\_shards" : 0,  
"unassigned\_shards" : 0,  
"delayed\_unassigned\_shards" : 0,  
"number\_of\_pending\_tasks" : 0,  
"number\_of\_in\_flight\_fetch" : 0,  
"task\_max\_waiting\_in\_queue\_millis" : 0,  
"active\_shards\_percent\_as\_number" : 100.0  
}

---

<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:** [December 15, 2017, 2:32am UTC](https://discuss.elastic.co/t/trying-to-setup-elasticsearch-cluster-with-docker-compose/106803/11 "2017-12-15T02:32:05Z")

</div>

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