Akka HTTP在docker容器中过早关闭

时间:2017-10-08 23:31:53

标签: scala docker akka-stream akka-http

我有一个简单的Akka HTTP服务器在端口8080上本地运行。它工作正常并显示以下消息:

Started server at 127.0.0.1:8080, press enter to kill server

我正在使用sbt-assembly来创建.jar文件。它位于target/scala-2.12/my-app-assembly-0.1.jar

之下

然后,我创建一个简单的Dockerfile,如:

FROM openjdk:8u131
ADD target/scala-2.12/my-app-assembly-0.1.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
CMD ["-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-XX:MaxRAMFraction=1", "-XshowSettings:vm"]

构建泊坞窗图像:

docker build -t {my namespace}/my-app .

运行它:

docker run {my namespace}/my-app

现在,它还会显示:

Started server at 127.0.0.1:8080, press enter to kill server

但在此之后,它会抛出这些错误并关闭:

...
[DEBUG] [10/08/2017 23:18:15.056] [default-akka.actor.default-dispatcher-7] [akka://default/system/IO-TCP/selectors/$a/0] Monitored actor [Actor[akka://default/user/StreamSupervisor-0/$$a#1560882800]] terminated
[DEBUG] [10/08/2017 23:18:15.060] [default-akka.actor.default-dispatcher-6] [akka://default/system/IO-TCP/selectors/$a/0] Closing serverSocketChannel after being stopped
[DEBUG] [10/08/2017 23:18:15.067] [default-akka.actor.default-dispatcher-4] [EventStream] shutting down: StandardOutLogger started

任何想法为什么会发生这种情况?

1 个答案:

答案 0 :(得分:4)

默认情况下,Docker关闭可能会影响您的应用的标准输入,因为它提示用户输入:press enter to kill server

Run the container with the -i option to keep stdin open

docker run -i {my namespace}/my-app

通常守护进程或服务器进程不应该要求这样做。