0
votes

I m new at docker so i tried to connect multiple container - mongo - my app - redis and i get this error in chrome=> code: "ECONNREFUSED", errno: "ECONNREFUSED", syscall: "connect", address: "127.0.0.1", port: 8080}

here is my docker-compose file :

version: "2"

services:
  mongo:
    image: "mongo"
    restart: always
    ports:
      - "27017:27017"
    networks:
     -  all
  redis:
    image: "redis:3.2.1"
    networks:
     -  all
  node:
    image: "project"
    links:
      - mongo
    ports:
      - "8080:8080"
    networks:
     -  all
  backoffice:
    image: "back"
    links:
      - node
      - mongo
      - redis
    depends_on:
      - mongo
      - node
      - redis
    ports:
      - "8181:8181"
    networks:
     -  all

networks:
  all:
    driver: bridge

my differents Dockerfile:

for mongo:

FROM mongo:2.6

COPY ./data ./

EXPOSE 27017

CMD ["mongod"]

for service node:

FROM node:4.4.7

WORKDIR /app

COPY /api ./

RUN npm install

RUN apt-get -q update && apt-get install -y -qq \ git \ curl

EXPOSE 8080

CMD ["node","index.js"]

for service back:

FROM node:4.4.7

WORKDIR /api

COPY . ./

RUN npm install && npm install bower -g && npm install gulp -g

RUN bower install --allow-root && gulp build

RUN apt-get -q update && apt-get install -y -qq \ git \ curl

EXPOSE 8181

CMD ["node","index.js"]

can you please help me figure this out ?

2

2 Answers

0
votes

Probably your port 8080 is already in use. Open your cmd and type netstat -a. This is for checking the ports availability.

0
votes

I solve my issue, i was using version 2 of docker-compose but links are available only from version 3. Just upgrade and it works fine.