Some confusion I am facing about the proper configuration to set to be able to access to my akka application deployed into a docker container. Though I am running a virtualbox ubuntu VM, I would like at first to be able to access the container from this VM before forwarding ports on the VM host. application.conf:
akka {
actor {
provider = remote
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = ${?HOSTNAME} # what should it be? 0.0.0.0 or the assigned docker one like 172.17.0.x but unknown in advance
port = ${?PORT} # 800
bind-hostname = ${?BIND_HOSTNAME} # 127.0.0.1 ?
bind-port = ${?BIND_PORT} # 800 ? xxxx ?
# 30Mb max msg
message-frame-size = 30000000b
send-buffer-size = 30000000
receive-buffer-size = 30000000b
maximum-frame-size = 30000000b
}
}
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "DEBUG"
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
}
my docker file that builds and runs the application properly according to the logs:
FROM openjdk:8u151
# Env variables
ENV SCALA_VERSION 2.12.4
ENV SBT_VERSION 1.1.1
# Scala expects this file
RUN touch /usr/lib/jvm/java-8-openjdk-amd64/release
# Install Scala
# Piping curl directly in tar
RUN \
curl -fsL https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz | tar xfz - -C /root/ && \
echo >> /root/.bashrc && \
echo "export PATH=~/scala-$SCALA_VERSION/bin:$PATH" >> /root/.bashrc
# Mk app dir
RUN mkdir /alor
# Define working directory
WORKDIR /alor
# Add target packaged app
COPY target/universal/stage/ /alor/
# Expose ports
EXPOSE 800
EXPOSE 5150
# Launch the app
CMD ./bin/alor
after running the image, I tried to access the address 172.17.0.x:800 after inspecting the container but without anything being logged on the container console.
Found my own solution, don't know if it comes down to akka issue in the binding configuration or that the raw openjdk image hasn't internal binding for local network as I tried different ones such as bind-hostname = 127.0.0.1 bind-port=xxx
but setting for example:
hostname = 172.17.0.2
port = 800
bind-hostname = 0.0.0.0
bind-port = ""
makes the akka system reachable from the outside world with 172.17.0.2:800
.
The ip of the docker container can use internal network as well instead of guessing it