Akka cluster bootstrap in Docker Compose

80 Views Asked by At

I'm trying to deploy a cluster with the following configuration:

 server1.address                          server2.address                                                                                        
+----------------------------+           +----------------------------+                                                                          
|  docker-compose            |           |  docker-compose            |                                                                          
| +------------------------+ |           | +------------------------+ |                                                                          
| |+----------------------+| |           | |+----------------------+| |                                                                          
| || Akka                 -------2551-------- Akka                 || |                                                                          
| ||                      -------9100--------                      || |                                                                          
| ||                      -------8100    | ||                      || |                                                                          
| |+----------------------+| |    |      | |+----------------------+| |                                                                          
| |+----------------------+| |    |      | |+----------------------+| |                                                                          
| || Service              ------------------- Service              || |                                                                          
| ||                      || |           | ||                      || |                                                                          
| |+----------------------+| |           | |+----------------------+| |                                                                          
| +------------------------+ |           | +------------------------+ |                                                                          
+----------------------------+           +----------------------------+     

I use Akka Cluster Bootstrap to initialize the cluster and akka.management.cluster.bootstrap.contact-point-discovery.discovery-method = config to define cluster nodes.

akka.remote.artery {
  canonical.hostname = ${?CURRENT_HOST}
  canonical.port = 2551
  bind.hostname = 0.0.0.0
  bind.port = 2551
}
akka.management.http {
  hostname = ${?CURRENT_HOST}
  port = 9100
  bind-hostname = 0.0.0.0
  bind-port = 9100
}

The problem is that Akka container cannot initialize cluster (using Cluster Bootstrap) because it cannot connect to itself using canonical (external) hostname. In general I cannot connect to host ports from within container.

The only solution I've found so far is to allow traffic from my docker compose network using sudo iptables -I INPUT 3 -i <compose-network> -j ACCEPT. Is it really a way to go?

0

There are 0 best solutions below