docker - Internal Tomcat REST calls to localhost from inside Docker container
问题描述
I have a dockerfile that runs a Tomcat 7 web server with two REST APIs, a PostgreSQL database, and a Django site on Apache. (I know that best practices suggest running these as separate containers, but I wanted to package the whole system as one container for usability by non-devs).
One of my REST API calls the other REST API through the endpoint http://localhost:8080/rest2/insert
. However, in bridge mode
in Docker, localhost
refers to the host, not the container.
I have tried hardcoding the container ip 172.17.0.2
but I still get a Connection Refused
error.
I assume this will be a problem for the localhost
PostgreSQL connection from rest1
as well. What are my options?
Any help is much appreciated!
解决方案
无论出于何种原因,该Connection Refused
错误是由 Docker 内存不足引起的。我增加了内存限制,一切都很好。希望这能帮助那些在未来挣扎的人!
推荐阅读
- java - 如何在类中将 int 的所有内部使用转换为 BigInteger
- python - Numpy - 为什么 Fortran 内存布局在逐行读取时比 C 布局快
- python - Python tkinter:NameError:未定义名称'tk'
- javascript - LineItem 上的 Netsuite 字段更改功能正在触发 2 次
- python - NLP 计算与 yes 和 no 列相关的评论列中的单词
- node.js - ExpressJS 在 POST 请求中显示空的 req.body 对象,但不包括 Insomnia 或 cURL
- html - 用图库中的视频替换图像
- python - Python Numpy Conv 混淆
- css - height/width: 100% 和 --webkit-fill-available 有什么区别
- amazon-web-services - EMR ignores spark submit parameters (memory/cores/etc)