[英]Created docker image for spring boot app, not accessible
I have created a docker image for my spring boot app "payalbnsl/shoppingapp"我为我的 Spring Boot 应用程序“payalbnsl/shoppingapp”创建了一个 docker 镜像
First i start the container for mongodb: "docker run -d -p 27017:27017 --name mongodb --network n1 -e MONGO_INITDB_ROOT_USERNAME=mongodb -e MONGO_INITDB_ROOT_PASSWORD=mongodb -e MONGO_INITDB_DATABASE=levent -e MONGO_USERNAME=mongodb -e MONGO_PASSWORD=mongodb mongo --auth"首先,我为 mongodb 启动容器:“docker run -d -p 27017:27017 --name mongodb --network n1 -e MONGO_INITDB_ROOT_USERNAME=mongodb -e MONGO_INITDB_ROOT_PASSWORD=mongodb -e MONGO_INITDB_DATABASE=wordlevent -e MONGO_USER- mongodb mongo --auth"
Then i run the image : "docker run -d --network n1 -p 9000:9000 payalbnsl/shoppingapp:1"然后我运行图像:“docker run -d --network n1 -p 9000:9000 payalbnsl/shoppingapp:1”
When i try to access the url " http://13.233.154.209:9000 ", it redirects to " http://13.233.154.209:9000/products ", like it should as coded.当我尝试访问网址“ http://13.233.154.209:9000 ”时,它会重定向到“ http://13.233.154.209:9000/products ”,就像编码一样。 But i keep getting 404 error.
但我不断收到 404 错误。 No page is displayed.
不显示页面。
Logs are exactly same both when running locally and on ec2 using docker使用 docker 在本地和 ec2 上运行时,日志完全相同
But locally i can see the web page但是在本地我可以看到网页
While running on ec2, i get this page:
在 ec2 上运行时,我得到了这个页面:
Though i just entered http://13.233.154.209:9000 , it redirects to http://13.233.154.209:9000/products on production, but i don't see any web page.
虽然我刚刚输入了http://13.233.154.209:9000 ,它在生产中重定向到http://13.233.154.209:9000/products ,但我没有看到任何网页。
I have opened up port 9000 for ec2 instance.我已经为 ec2 实例打开了 9000 端口。
Why there is 404, i cannot understand.为什么有 404,我无法理解。 I am using JSP for frontend.
我正在使用 JSP 作为前端。
Application has successfully connected to mongo.应用程序已成功连接到 mongo。 Both are on bridge network n1.
两者都在桥接网络 n1 上。 I have enabled firewall on this port.
我在这个端口上启用了防火墙。 Even if i run this application locally using docker it gives same 404. On any instance, i am getting 404.
即使我使用 docker 在本地运行这个应用程序,它也会给出相同的 404。在任何情况下,我都会得到 404。
Also for me "curl -i --unix-socket /var/run/docker.sock http://localhost/containers/json " works while "curl -i --unix-socket /var/run/docker.sock http://containers/json " gives 404. Not sure what it means exactly.同样对我来说,“curl -i --unix-socket /var/run/docker.sock http://localhost/containers/json ” 可以工作,而“curl -i --unix-socket /var/run/docker.sock http ://containers/json " 给出 404。不确定它的确切含义。
Any help would be really appreciated!任何帮助将非常感激!
Thanks, Payal谢谢,佩亚尔
It was a spring boot jsp problem.这是一个spring boot jsp问题。 I had placed jsps in the webapp folder and when i created an executable jar file, jsps were not copied.
我已经将 jsps 放在 webapp 文件夹中,当我创建一个可执行的 jar 文件时,jsps 没有被复制。 Hence created a war file and redeployed.
因此创建了一个战争文件并重新部署。 It worked.
有效。 Resolved!
解决!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.