Spring Docker容器未在浏览器上运行

Spring Docker容器未在浏览器上运行,spring,docker,spring-mvc,dockerfile,Spring,Docker,Spring Mvc,Dockerfile,我已经通过docker将我的应用程序打包到本地。这是一个spring mvc应用程序,它成功启动 Web application available (default_host): http://479c9c236b5f:9080/ibm/saml20/ [AUDIT ] CWWKT0016I: Web application available (default_host): http://479c9c236b5f:9080/IIT/ [AUDIT ] CWWKZ0001I: App

我已经通过docker将我的应用程序打包到本地。这是一个spring mvc应用程序,它成功启动

 Web application available (default_host): http://479c9c236b5f:9080/ibm/saml20/
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://479c9c236b5f:9080/IIT/
[AUDIT   ] CWWKZ0001I: Application IIT started in 10.076 seconds.
[AUDIT   ] CWWKF0012I: The server installed the following features: [appSecurity-2.0, appSecurity-3.0, cdi-2.0, distributedMap-1.0, el-3.0, federatedRegistry-1.0, jndi-1.0, jsp-2.3, ldapRegistry-3.0, localConnector-1.0, samlWeb-2.0, servlet-4.0, ssl-1.0, transportSecurity-1.0].
[AUDIT   ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 26.691 seconds.

我使用命令docker run-p8080:8080我的docker来运行我的图像,但是当我点击http://localhost:8080/IIT/ 在浏览器中,我们说“连接被重置”时出错了。

我对spring mvc不太了解,但根据您的描述,它看起来像是使用(http://479c9c236b5f:9080)9080端口和外部您正在使用8080端口

请应用
docker run-p8080:9080我的docker
访问它。
如果您使用的是Dockerfile,请同时在Dockerfile中提及
EXPOSE 9080

您的web应用程序运行在端口9080上,而不是8080上…我已在Dockerfile中公开了9080。现在,当我点击localhost:9080/IIT/时,浏览器仍然无法连接为什么点击localhost:9080,9080是应用程序运行的容器内部端口。您必须点击localhost:8080,因为8080是应用程序通信的外部端口。对不起。我的错。提到错误的端口命中8080也会导致同样的问题。