[英]Can't reach localhost:8080 while running docker image
I have developed a small Java demo web app, using gradle, which I want to dockerize with WildFly. 我使用gradle开发了一个小型的Java演示Web应用程序,我想通过WildFly对其进行dockerize。 I have followed instructions from here .
我遵循了这里的指示。
The Dockerfile
is: Dockerfile
是:
FROM jboss/wildfly
MAINTAINER Me <me@qmail.com>
RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#70365 --silent
ADD build/libs/my-demo.war /opt/jboss/wildfly/standalone/deployments/
When I start the image with Docker and browse localhost:8080
or localhost:9990
, I get a This site can't be reached
. 当我用Docker启动映像并浏览
localhost:8080
或localhost:9990
,我得到一个This site can't be reached
。
Yet, my application runs successfully on localhost:8080
when I use gradle appRun
. 但是,当我使用
gradle appRun
时,我的应用程序可以在localhost:8080
上成功运行。
What is missing? 什么东西少了?
I am under Windows 10 Home Edition. 我使用Windows 10家庭版。 I have tried on another laptop under Ubuntu 16 and face the same issue.
我曾在Ubuntu 16下尝试在另一台笔记本电脑上使用,并且遇到相同的问题。
Three things: 三件事:
1st the base image EXPOSE
s only port 8080, so to be able to access port 9990 you need to add EXPOSE 9990
to your Dockerfile or --expose 9990
to your docker run
call. 第一个基本映像
EXPOSE
的唯一端口是8080,因此要访问端口9990,您需要将EXPOSE 9990
添加到Dockerfile或--expose 9990
到--expose 9990
docker run
调用。
2nd You didn't post your cmd line call, so I can only guess but you need to map the container port to a host port, example (including the additional exposed port) 2您没有发布cmd线路呼叫,因此我只能猜测,但是您需要将容器端口映射到主机端口,例如(包括附加的暴露端口)
docker run --expose 9990 -p 9990:9990 -p 8080:8080 -it my-demo
3rd If your working with docker-machine as it is still the case with Win 10 home as far as I recall, you won't have your application on localhost but at the IP of the docker-machine VM. 第三如果据我记得,如果使用Win 10 home仍然使用docker-machine,那么您的应用程序将不在localhost上,而是在docker-machine VM的IP上运行。 You can find out which IP that is by calling
您可以通过拨打电话找出哪个IP
docker-machine ip
On linux you will have your app on localhost:PORT once you add the port mapping. 在Linux上,添加端口映射后,您的应用程序将在localhost:PORT上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.