我在设置正确配置以能够访问部署到 docker 容器中的 akka 应用程序时遇到一些困惑。虽然我正在运行一个 virtualbox ubuntu VM,但我首先希望能够在 VM 主机上转发端口之前从该 VM 访问容器。应用程序.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"
}
我的 docker 文件根据日志正确构建和运行应用程序:
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
运行映像后,我在检查容器后尝试访问地址 172.17.0.x:800 但没有在容器控制台上记录任何内容。