diff --git a/elasticsearch/README.md b/elasticsearch/README.md index e4c6ab47..ea69a5b3 100755 --- a/elasticsearch/README.md +++ b/elasticsearch/README.md @@ -169,3 +169,15 @@ The minimum, which can be calculated as `(master_eligible_nodes / 2) + 1`, can b Using the Docker Compose file above, a value of `2` is appropriate when scaling the cluster to 3 master nodes: docker-compose scale master=3 + +## Auto transport discovery with Swarm Mode + +When using Docker Swarm mode (starting with 1.12), the overlay and ingress network interfaces are assigned +multiple IP addresses. As a result, it creates confusion for the transport publish logic even when using +the special value `_eth0_`. + +To resolve this, add + + -e DISCOVER_TRANSPORT_IP=eth0 + +replacing `eth0` with another interface within the container, if needed. diff --git a/elasticsearch/start b/elasticsearch/start index 0675a99d..c3ff5256 100755 --- a/elasticsearch/start +++ b/elasticsearch/start @@ -18,6 +18,12 @@ OPTS="$OPTS -Des.path.conf=/conf \ -Des.transport.tcp.port=9300 \ -Des.http.port=9200" +if [ "$DISCOVER_TRANSPORT_IP" != "" ]; then + ip=`ipaddr show dev $DISCOVER_TRANSPORT_IP scope global|awk '$1 == "inet" { if (!match($2,"/32")) { gsub("/.*","",$2) ; print $2 } }'` + echo "Discovered address $ip for $DISCOVER_TRANSPORT_IP" + OPTS="$OPTS -Des.transport.host=$ip" +fi + if [ -n "$CLUSTER" ]; then OPTS="$OPTS -Des.cluster.name=$CLUSTER" if [ -n "$CLUSTER_FROM" ]; then