Saturday, 3 June 2017

docker-compose node application cannot connect internet

I am having an issue with docker-compose containers. There is certainly an answer somewhere but it seems I don't have the vocabulary necessary to find it, sorry.

Here is my docker-compose file :

version: '2'

services:
    gateway-linkcs:
        image: node:7
        ports:
          - 3000:3000
        volumes:
          - ../Gateway:/usr/src/app
        working_dir: /usr/src/app
        command: yarn startdev
        networks:
          - back-linkcs
    postgres-user-linkcs:
        build:
            context: ../User
            dockerfile: docker/Dockerfile
        networks:
          - back-linkcs
    dev-user-linkcs:
        image: node:7
        ports:
          - 3001:3001
        volumes_from:
          - postgres-user-linkcs
        volumes:
          - ../User:/usr/src/app
        working_dir: /usr/src/app
        command: /usr/src/app/docker/scripts/start-node.sh
        environment:
          - NODE_ENV=development # change to 'production' for prod
          - GATEWAY_ADDRESS=gateway-linkcs:3000
        networks:
          - back-linkcs

networks:
    back-linkcs:

My node application in dev-user is suppose to use gateway as a proxy to connect an api on the internet, and dev-user actually finds gateway, and is able to connect to it (using hostname 'gateway-linkcs') However, my gateway app cannot connect to the external API :

Error: getaddrinfo ENOTFOUND api.xxx api.xxx:80
     at errnoException (dns.js:28:10)
     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:73:26)

I have tested starting the gateway outside of docker, (node index.js) and it works perfectly well.

I think I am missing something with docker-compose networks, can someone help ?

Thank you very much, Giltho.



via Giltho

No comments:

Post a Comment