gpt4 book ai didi

spring-boot - docker部署成功后无法在localhost上连接应用程序

转载 作者:行者123 更新时间:2023-12-02 18:09:50 44 4
gpt4 key购买 nike

我正在尝试在 docker 容器 上部署 Spring Boot War 文件
这是我的 docker 文件:

FROM tomcat:alpine

RUN wget -O /usr/local/tomcat/webapps/ROOT.war -U admin:Learning http://localhost:8082/artifactory/demoArtifactory/com/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.war

EXPOSE 8080

CMD ["catalina.sh", "run"]
enter image description here
enter image description here
我无法连接到 localhost:7000
更新:
这是 docker 运行命令:

docker run -it --name demo-application -d -p 8080:8080hmt/demo-application:49

"PortBindings": {
"8080/tcp": [
{
"HostIp": "",
"HostPort": "8080"
}
]
}
现在我的 tomcat 已在 localhost:8080 上运行,但我无法访问我的应用程序
更新:
@SpringBootApplication
public class DemoApplication{

public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}

}

最佳答案

查看您的端口信息:
端口9100容器的发布在端口 7000在主机上。
但是看看你的日志应用程序:它部署在 8080 (而不是在 9100 上)。
你想要的是发布容器端口80807000主机端口,例如:

docker run -p 7000:8080 foo-image

关于spring-boot - docker部署成功后无法在localhost上连接应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63548197/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com