akka http: docker 容器未连接到服务器
akka http: docker container is not connecting to the server
我有一个 akka htpp 应用程序,这是我绑定它的方式
val host = "0.0.0.0"
val port = 8080
val bindingFuture = Http().bindAndHandle(MainRouter.routes, host, port)
log.info("Server online ")
StdIn.readLine()
bindingFuture
.flatMap(_.unbind()) // trigger unbinding from the port
.onComplete(_ => system.terminate()) // and shutdown when done
我正在使用 sbt native packager 创建我的应用 docker 图片
我也添加了
dockerExposedPorts:= Seq(8080)
在我的 build.sbt
我是 运行 我的容器
docker run -p 8080:8080 testapp:0.0.1 --bind 0.0.0.0
docker ps
显示
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2e8e7ae35b10 testapp:0.0.1 "/opt/docker/bin/tes…" 13 minutes ago Up 13 minutes 0.0.0.0:8080->8080/tcp recursing_hellman
当我从浏览器中点击 0.0.0.0:8080 时,我得到了
This site can’t be reached The connection was reset.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_RESET
或来自postman
Could not get any response
There was an error connecting to 0.0.0.0:8080/event-id?id=132
而 docker 容器在我的机器上 运行
数控-zv 0.0.0.0 8080
returns
Connection to 0.0.0.0 8080 port [tcp/http-alt] succeeded!
容器内
docker exec -it 2e8e7ae35b10 bash
我试过了
curl 'http://0.0.0.0:8080/health'
curl: (7) Failed to connect to 0.0.0.0 port 8080: Connection refused
我的应用在 docker
之外运行良好
我认为问题在于 docker 默认情况下关闭标准输入,这可能会影响您的应用,因为它会提示用户输入 StdIn.readLine()
。解决方案可能是 run the container with the -i
option to keep stdin open.
如果有帮助请告诉我!!
我有一个 akka htpp 应用程序,这是我绑定它的方式
val host = "0.0.0.0"
val port = 8080
val bindingFuture = Http().bindAndHandle(MainRouter.routes, host, port)
log.info("Server online ")
StdIn.readLine()
bindingFuture
.flatMap(_.unbind()) // trigger unbinding from the port
.onComplete(_ => system.terminate()) // and shutdown when done
我正在使用 sbt native packager 创建我的应用 docker 图片
我也添加了
dockerExposedPorts:= Seq(8080)
在我的 build.sbt
我是 运行 我的容器
docker run -p 8080:8080 testapp:0.0.1 --bind 0.0.0.0
docker ps
显示
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2e8e7ae35b10 testapp:0.0.1 "/opt/docker/bin/tes…" 13 minutes ago Up 13 minutes 0.0.0.0:8080->8080/tcp recursing_hellman
当我从浏览器中点击 0.0.0.0:8080 时,我得到了
This site can’t be reached The connection was reset.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_RESET
或来自postman
Could not get any response
There was an error connecting to 0.0.0.0:8080/event-id?id=132
而 docker 容器在我的机器上 运行 数控-zv 0.0.0.0 8080 returns
Connection to 0.0.0.0 8080 port [tcp/http-alt] succeeded!
容器内
docker exec -it 2e8e7ae35b10 bash
我试过了
curl 'http://0.0.0.0:8080/health'
curl: (7) Failed to connect to 0.0.0.0 port 8080: Connection refused
我的应用在 docker
之外运行良好我认为问题在于 docker 默认情况下关闭标准输入,这可能会影响您的应用,因为它会提示用户输入 StdIn.readLine()
。解决方案可能是 run the container with the -i
option to keep stdin open.
如果有帮助请告诉我!!