无法在裸露的端口上连接到Docker映像

时间:2019-12-25 19:18:31

标签: docker

我正在通过docker运行我的play framework应用程序。图像开始正常,但无法在Web浏览器上使用localhost:9000连接到应用程序。我可能做错了什么?我在Dockerfile中暴露了端口9000。

应用程序启动时的跟踪

docker run codingjediweb-1.0-snapshot
[debug] p.a.l.c.ActorSystemProvider - Starting application default Akka system: application
[info] play.api.Play - Application started (Prod)
[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0.0.0.0:9000

Dockerfile

FROM openjdk:8
ENV APP_NAME      my-app
ENV APP_VERSION   1.0-SNAPSHOT
#make a directory deploy in the container
RUN mkdir deploy
#cd to container
WORKDIR deploy
#copy from host (path relative to location of Dockerfile on host) to deploy directory. The deploy directory will have my-app-1.0.zip, logback_prod.xml and application_prod.xml
COPY target/universal/my-app-1.0.zip .
COPY conf/logback_prod.xml .
COPY conf/application_prod.conf .
#unzip deploy/my-app-1.0.zip in container
RUN unzip my-app-1.0.zip
#chmod my-app script in deploy/my-app-1.0/bin/my-app
RUN chmod +x my-app-1.0/bin/my-app
EXPOSE 9000
#entrypoint is deploy/....
ENTRYPOINT my-app-1.0/bin/codingjediweb -Dplay.http.secret.key=changemeplease -Dlogger.file=logback_prod.xml -Dconfig.file=application_prod.conf

1 个答案:

答案 0 :(得分:0)

我不得不使用参数-p 9000:9000。在What is the difference between "expose" and "publish" in Docker?

中有更多详细信息