这是我的 docker 组成
services:
api:
image: api
container_name: api
ports:
- "3000:3000"
external_links:
- front
networks:
- global
front:
image: front
container_name: front
ports:
- "8080:80"
external_links:
- api
networks:
- global
networks:
global:
我正在尝试从ui容器调用api。
这是通话网址:http://api:3000/api/search?query=ihpone&page=1&minPrice=0&maxPrice=9999
我收到错误ERR_NAME_NOT_RESOLVED
有人可以帮助我吗?如何解决我的问题。如何从ui容器向api容器发出请求?
最佳答案
在浏览器上打开UI应用程序时,实际上是将其下载到主机(安装了docker的计算机)上,然后调用了API。
因此,在您的示例中,您需要在UI应用程序的配置中将url设置为: localhost:3000 而不是 api:3000
关于angular - 从docker ui容器调用到api容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59583086/