在我的windows笔记本电脑上,我创建了一个Play应用程序,如果我直接执行它的脚本,它运行良好。在本地机器上,我使用localhost:9000URL 访问应用程序。
我现在已经创建了Docker应用程序的图像并暴露了端口9000
#this docker file copies prod specific files to container, eg logback_prod.xml and application_prod.conf
FROM openjdk:8
#ENV APP_NAME myapp
#ENV APP_VERSION 1.0-SNAPSHOT
...
#entrypoint is deploy/....
EXPOSE 9000
ENTRYPOINT ...
但我无法访问localhost:9000. 我怀疑该图像可能在 docker 本身创建的其他一些 IP 上运行。
我对么?如何通过容器访问我的应用程序?我不需要Kubernetes Services等,因为我已经在另一台机器上进行了该设置。我的具体问题是如何docker直接访问容器。
更新我也尝试运行docker imageusing--network="host"但这也不起作用
更新 2
根据以下建议,我执行了以下命令,但仍然无法访问该应用程序。
docker run -p 9000:9000 --env-file env.txt imagename
我看到了痕迹
[debug] a.i.TcpListener - Successfully bound to /0.0.0.0:9000
[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0.0.0.0:9000
docker ps -a显示应用程序已启动端口绑定0.0.0.0:9000->9000/tcp
docker inspect显示IP-"IPAddress": "172.17.0.2"
但是http://172.17.0.2:9000/onChrome不起作用This site can’t be reached172.17.0.2
netstat -ab在cmd节目中TCP 0.0.0.0:9000 LAPTOP-788I0GL1:0 LISTENING [com.docker.backend.exe]