我正在尝试使docker-compose中的angular和nginx容器在google-compute vm实例(Debian OS)上互相交谈,但没有成功。这是我的docker-compose.yml:
version: '3'
services:
angular:
container_name: angular
hostname: angular
build: project-frontend
ports:
- "80:80"
#network_mode: host
nodejs:
container_name: nodejs
hostname: nodejs
build: project-backend
ports:
- "8080:8080"
# network_mode: host
我已经阅读了docs和许多诸如this之类的SO帖子,并且了解到angular应该试图在http://nodejs:8080/处找到节点,但是我得到了:
POST http://nodejs:8080/login/ net::ERR_NAME_NOT_RESOLVED
[我做docker networkk inspect
时看到此
[
{
"Name": "project_default",
"Id": "abe97d4c97e51806388ee36d19608c45c2e90033ee738588603623b9958375d5",
"Created": "2020-05-22T10:30:20.036068212Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.24.0.0/16",
"Gateway": "172.24.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
我不确定还有哪些其他步骤可以帮助我进行调试。谢谢。
您需要确保它们在同一网络上。您可以通过在撰写文件的末尾添加以下几行来完成此操作
networks:
default:
external:
name: project.local