'Api Gateway not see other services in docker container

I have a problem with containerization of my small microservice project with using docker-compose. After build and up belowed compose I see that everythin is working and all services is running, but right now I have a one issue. My api-gateway service is not connecting to the other services and when api-gateway is trying to make request to eq. account-service then console throw me this:

api-gateway  | [Nest] 1  - 05/21/2022, 9:38:51 PM   ERROR [ExceptionsHandler] connect ECONNREFUSED 127.0.0.1:3002

So, I think that the problem is in connection in my container, between all of the services in him.

Can someon tell me what have i'm doing wrong?

Here is my docker-compose.yml

version: '3'

networks:
  backend:
    driver: bridge
    
services:
  api:
    container_name: api-gateway
    build:
      context: .
      dockerfile: ./apps/api/Dockerfile
    restart: always
    hostname: api
    env_file:
      - .env
    ports:
      - "3000:3000"
    networks:
      - backend
  account:
    container_name: account-service
    build:
      context: .
      dockerfile: ./apps/account/Dockerfile
    restart: always
    hostname: account
    env_file:
      - .env
    ports:
      - "3001:3001"
    networks:
      - backend
  workspace:
    container_name: workspace-service
    build:
      context: .
      dockerfile: ./apps/workspace/Dockerfile
    restart: always
    hostname: workspace
    env_file:
      - .env
    ports:
      - "3002:3002"
    networks:
      - backend

Dockerfile

FROM node:14.8.0-alpine as develop

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install
COPY . .

RUN npm run build workspace

CMD node dist/apps/workspace/main

Dockerfile is this same for all of the services.

Thanks for any help!



Solution 1:[1]

in your example:

klassName = MyClass

class klassName(models.Model):
    title = models.CharField(max_length=30)

klassName referenced to nothing, because MyClass is not defined. You can say:

MyClass = klassName

class klassName(models.Model):
    title = models.CharField(max_length=30)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pythonaire