Elasticsearch docker containers - unable to add second node

Hello,

I am trying to deploy a 2 node elasticsearch test cluster in docker and was able to get up the first node as the master without any issues but when I try to startup the second es docker container it sees the master but is unable to connect to it:

...
[2017-11-05T19:17:13,088][WARN ][o.e.d.z.ZenDiscovery ] [vZOTb7p] failed to connect to master [{ZwL2Awq}{ZwL2Awq6TniXsKKQJfvz2w}{lB-onkBQQ3mUQj08qVQE9g}{172.17.0.3}{172.17.0.3:9300}{ml.enabled=true}], retrying...
org.elasticsearch.transport.ConnectTransportException: [ZwL2Awq][172.17.0.3:9300] connect_timeout[30s]
at org.elasticsearch.transport.netty4.Netty4Transport.connectToChannels(Netty4Transport.java:361) ~[?:?]
at org.elasticsearch.transport.TcpTransport.openConnection(TcpTransport.java:548) ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.transport.TcpTransport.connectToNode(TcpTransport.java:472) ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:332) ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:319) ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.discovery.zen.ZenDiscovery.joinElectedMaster(ZenDiscovery.java:459) [elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.discovery.zen.ZenDiscovery.innerJoinCluster(ZenDiscovery.java:411) [elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.discovery.zen.ZenDiscovery.access$4100(ZenDiscovery.java:83) [elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.discovery.zen.ZenDiscovery$JoinThreadControl$1.run(ZenDiscovery.java:1188) [elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:569) [elasticsearch-5.5.0.jar:5.5.0]
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]
...

Here is my elasticsearch.yml file:

...
cluster:
name: ${CLUSTER_NAME}

path:
data: /data/data
logs: /data/log

bootstrap:
memory_lock: true

http:
enabled: ${HTTP_ENABLE}
compression: true
cors:
enabled: true
allow-origin: "/.*/"

discovery:
zen:
minimum_master_nodes: 1

network.host: site

xpack.security.enabled: false
node.max_local_storage_nodes: 4
discovery.zen.ping.unicast.hosts: ["a.a.a.a", "b.b.b.b", "c.c.c.c", "d.d.d.d"]
...

Any help would be greatly appreciated!

Thanks in advance.

What does the dockerfile look like?

This is the dockerfile that I used to build this container:

...
FROM docker.elastic.co/elasticsearch/elasticsearch:5.5.0
ADD elasticsearch.yml /usr/share/elasticsearch/config/
USER root
RUN chown elasticsearch:elasticsearch config/elasticsearch.yml
USER elasticsearch
...

Thanks!

Just a bit of a tip, if you replace the 3 dots you use with ``` (back ticks) you can change the text to code :slight_smile:

We'd definitely suggest using the latest version of Elasticsearch, which is currently 5.6.3. Luckily docker makes that simple to do!

Also have a look at https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docker.html#docker-cli-run-prod-mode, specifically just under this section, which provides an example of how to run multiple nodes using docker compose.