Think I've got it!  Here's the recipe for application.conf I got working to 
make Akka clustering work w/Docker:

akka {
loglevel = "ERROR"
stdout-loglevel = "ERROR"
loggers = ["akka.event.slf4j.Slf4jLogger"]
actor {
provider = akka.cluster.ClusterActorRefProvider
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
# Outside Docker
bind-hostname = ${dkr.local}

# Inside Docker addr
hostname = ${dkr.hostname}
port     = ${dkr.port}
}
}
cluster {
auto-down = on
log-info = off
}
}

Key Points:

1) seed-nodes (and roles FWIW) are set by my program but could be added to 
the cluster section here.  I happen to pass them into Docker via a 
parameter.  The IPs of the seeds are host IPs not the Docker-internal IPs 
(which I basically don't care about).

2) dkr.hostname/dkr.port are passed into Docker via parameters.  This is 
the *host* IP/port you want to run on (i.e. Docker-external IP addr). 
 Although I don't happen to care, I believe this also runs Akka on the same 
port inside Docker.  It might be an issue if you are running lots of things 
in your Docker container using ports, but I'm just running Akka, so I'm not 
picky.

3) dkr.local is set by my program (not passed in) and is just the 
Docker-internal IP address (retrieved by 
java.net.InetAddress.getLocalHost().getHostAddress()).

Took a little doing to get this right but it works.  This new binding 
functionality is a fantastic addition to Akka, as Docker is really a DevOps 
darling.  Looking forward to full 2.4 release!

On Monday, December 29, 2014 2:03:33 PM UTC-6, tigerfoot wrote:
>
> Hello,
>
> I'm trying to figure out how to get 2.4-SNAPSHOT going with Docker such 
> that 1) I can access akka+http outside the running Docker container (i.e. 
> from the host), and 2) I can enable clustering/discovery.  
>
> I see from discussion threads and docs that the new bind-hostname and 
> bind-port are designed to do this, but I haven't been able to come up with 
> the right recipe to use them yet.
>
> My code passes these arguments when Docker starts up:
>    - IP address of host machine
>    - port for Akka on host
>    - http port
>
> Like this:
>
> docker run -i -t -p 9100:9100 -p 9101:9101 localhost:5000/root:1.0.0 
> --seed --name kernel --hostIP 172.16.240.78 --hostPort 9100 --httpPort 9101 
> --roles seed
>
> (where 172.16.240.78 is the IP of my host running Docker)
>
> Here's my application.conf.  
>
> akka {
> loglevel = "ERROR"
> stdout-loglevel = "ERROR"
> event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
> log-dead-letters = 1
> log-dead-letters-during-shutdown = off
>
> actor {
> provider = "akka.cluster.ClusterActorRefProvider"
> }
> remote {
> enabled-transports = ["akka.remote.netty.tcp"]
> netty.tcp {
> # Outside Docker addr
> bind-hostname  = ${server.ip}   # hostIP param
> bind-port      = ${server.port} # hostPort param
>
> # Inside Docker addr
> port           = 0
> }
> }
> cluster {
> auto-down = on
> log-info = off
> # seed-nodes and roles set at runtime and added to config
> }
> }
>
> I'm not sure I'm using these hostname/port, bind-hostname, bind-port 
> correctly.  I've tried a few different permutations, which either fail to 
> launch (w/messages saying it can't bind to an address) or it runs but I 
> can't hit it outside my Docker container.
> I need Akka to be able to discover its cluster nodes and be accessible on 
> the given IP addr/port.
>
> I have a trivial project set up here to show the approach:  
> https://github.com/gzoller/docker-exp/tree/akk2
>
> I'm hoping I'm missing something simple in my config...
>
> Any ideas?
>
> Thanks!
> Greg
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to