Docker Community Forums

Share and learn in the Docker community.

How to connect my docker compose file with localhost microservices

Below are mu docker-compose.yml file and try to communicate with other services localhost but connection refused while executing API.

Code here

version: '3.9'
services:
  gateway:
    image: servicelayernode_gateway
    build:
      context: ./servicelayernode_gateway
      dockerfile: ./servicelayernode_gateway/Dockerfile
    ports:
      - 3001:3001
    environment:
      TZ: America/Toronto
      NODE_TLS_REJECT_UNAUTHORIZED: 0
      FLASK_ENV: development
      DOCKER_HOST: http://127.0.0.1:3001
      URL: http://localhost:3001
  ems:
    image: servicelayernode_service_ems
    build:
      context: ./servicelayernode_gateway
      dockerfile: ./servicelayernode_service_ems/Dockerfile
    ports:
      - 3005:3005
    depends_on:
      - gateway
    environment:
      TZ: America/Toronto
      NODE_TLS_REJECT_UNAUTHORIZED: 0
      FLASK_ENV: development
      URL: http://localhost:3005
    link: gateway
networks:
  default:
    # Use a custom driver
    driver: bridge