下面是我的docker-compose.yml文件,具有3个服务。
version: '3.0'
services:
mongodb:
build: ./mongodb
image: mongo:1.0
container_name: mongodb
ports:
- "27017:27017"
networks:
- appNetwork
node-service:
build: ./node-service
image: node-service-live:1.0
container_name: node-service
command:
sh -c "dockerize -wait tcp://mongodb:27017 -timeout 1m && npm start"
expose:
- "3031"
ports:
- "3031:3031"
networks:
- appNetwork
angular-app:
build: ./angular-app
image: angular-app-live:1.0
container_name: angular-app
command: ng serve --host 0.0.0.0 --port 4201 --disable-host-check
ports:
- "4201:4201"
networks:
- appNetwork
networks:
appNetwork:
external: true
当我执行docker-compose up
时,node-service
可以使用以下链接连接到mongodb
服务:mongodb://mongodb:27017/DBName?authMechanism=DEFAULT
。
但是angular-app
服务尽管位于同一网络中,仍无法与node-service
通信。在angular-app
中,我使用以下链接(http://node-service:3031
)连接到node-service
。
我想念什么?