最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

http - A REST API from inside a container is NOT accessible from other container on the same host - Stack Overflow

programmeradmin2浏览0评论

I have a REST API running from a container but the port is published so I can access the web service from any machine using . Everything is good.

Now, I have another application running on a different container on the same host, which should consumes the web service (running in the other container). For some reason, the web service always returns 400 Bad Request when trying to consume from the app in the container...

If trying the app from the same host or outside, it always works! I'm not sure if I 'm missing some configuration, but calling the API from inside a container, shouldn't be the same if using the URL?

I would appreciate any help.
Gus

I have a REST API running from a container but the port is published so I can access the web service from any machine using https://myapi/myservice. Everything is good.

Now, I have another application running on a different container on the same host, which should consumes the web service (running in the other container). For some reason, the web service always returns 400 Bad Request when trying to consume from the app in the container...

If trying the app from the same host or outside, it always works! I'm not sure if I 'm missing some configuration, but calling the API from inside a container, shouldn't be the same if using the https://myapi/myservice URL?

I would appreciate any help.
Gus

Share Improve this question edited Nov 21, 2024 at 6:30 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Nov 21, 2024 at 2:39 Gus SabinaGus Sabina 3112 silver badges15 bronze badges 2
  • 400 Bad Request which means that it is hitting a server and it is responding to your request. Could you just be sending an invalid request? – Jason Gallagher Commented Nov 21, 2024 at 2:46
  • Please share a minimal reproducible example – OneCricketeer Commented Nov 21, 2024 at 2:54
Add a comment  | 

1 Answer 1

Reset to default 0

For first step,maybe you should check DNS resolution name inside of the container that you're tying to call.

or trying to do the telnet first whether the expected port can be called inside container. Just for crosscheck.

Or better use container port directly to call the other container For example, if the API container is named api-service, you can access it using http://api-service:port/myservice

instead of using public domain

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论