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
请确保还从 properties 文件(基于您的个人资料)(默认/开发/测试)。
Make sure you also expose the same port from your properties
file based on your profile (default/dev/test).