docker映像正在运行,但无法访问Spring Boot应用程序中的其余端点 [英] docker image running but can't access rest endpoint in spring boot application

查看:118
本文介绍了docker映像正在运行,但无法访问Spring Boot应用程序中的其余端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个spring-boot应用程序,当使用maven生成并运行它时,它就可以正常工作了。但是当我运行我的应用程序的docker时,它正在控制台中运行,但是我无法访问任何REST终结点浏览器,这使页面找不到错误。

I have created a spring-boot application, when build and run it using maven it was working success full. But when i ran docker of my app it was running in the console but i can't access any REST endpoint browser is giving page not found error.

这里是内容我的 Dockerfile

FROM java:8
EXPOSE 5555:5555
ADD /hotline-api/target/hotline-api.jar hotline-api.jar
ENTRYPOINT ["java","-jar","hotline-api.jar","--spring.profiles.active=test"]


推荐答案

您还在运行映像时需要发布端口

You also need to publish the port while running your image

docker run -p 5555:5555 IMAGE_NAME






请确保还从<$中公开了相同的端口c $ c> properties 文件(基于您的个人资料)(默认/开发/测试)。


Make sure you also expose the same port from your properties file based on your profile (default/dev/test).

这篇关于docker映像正在运行,但无法访问Spring Boot应用程序中的其余端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆