docker-compose服务无法互相通信

时间:2018-10-15 11:35:44

标签: docker docker-compose

下面是我的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

我想念什么?

0 个答案:

没有答案