typescriptdockerdocker-composedockerfilenestjs

The system cannot find the file specified typescript


I'm trying to run build containers in docker but im getting an error The system cannot find the file specified

Docker version 27.3.1, build ce12230
Docker Desktop 4.35.1 (173168)
Windows 11 Pro version 23H2

the error is happening when I run

docker compose -f docker-compose.dev.yml up --build

You can see folder structure in the image, I want to mention something that I'm finding it strange when I run the command why it ends with you-app-backend ?

resolve : CreateFile C:\Users\user\Desktop\YOUAPP_FULLSTACK_PROJECT\you-app-backend\notification-microservice\you-app-backend:

Shouldn't be notification-microservice only? In addition, why every time when I run the command the path is changing to another microservice?

docker error

docker compose

services:
  youapp-frontend-container:
    build:
      context: ./you-app-frontend
      dockerfile: Dockerfile.dev
    container_name: youapp-frontend-container
    ports:
      - "5300:5300"
    volumes:
      - ./you-app-frontend:/youapp_fullstack_project
      - /youapp_fullstack_project/node_modules
    env_file:
      - ./you-app-frontend/.env
    depends_on:
      - api-gateway-container

  api-gateway-container:
    build:
      context: ./you-app-backend
      dockerfile: api-gateway/Dockerfile.dev
    container_name: api-gateway-container
    ports:
      - "3000:3000"
    volumes:
      - ./you-app-backend/api-gateway:/youapp_fullstack_project/you-app-backend/api-gateway
      - /youapp_fullstack_project/you-app-backend/api-gateway/node_modules
      - ./you-app-backend/shared:/youapp_fullstack_project/you-app-backend/shared
    env_file:
      - ./you-app-backend/api-gateway/.env
    environment:
      - RABBITMQ_URL=amqp://guest:guest@rabbitmq:5673
    depends_on:
      - auth-microservice
      - mongo

  auth-microservice:
    build:
      context: ./you-app-backend
      dockerfile: auth-microservice/Dockerfile.dev
    container_name: auth-microservice
    ports:
      - "4001:4001"
    volumes:
      - ./you-app-backend/auth-microservice:/youapp_fullstack_project/you-app-backend/auth-microservice
      # - /youapp_fullstack_project/you-app-backend/auth-microservice/node_modules
      - ./you-app-backend/shared:/youapp_fullstack_project/you-app-backend/shared
    env_file:
      - ./you-app-backend/auth-microservice/.env
    depends_on:
      - mongo

  user-microservice:
    build:
      context: ./you-app-backend
      dockerfile: user-microservice/Dockerfile.dev
    container_name: user-microservice
    ports:
      - "6001:6001"
    volumes:
      - ./you-app-backend/user-microservice:/youapp_fullstack_project/you-app-backend/user-microservice
      # - /youapp_fullstack_project/you-app-backend/user-microservice/node_modules
      - ./you-app-backend/shared:/youapp_fullstack_project/you-app-backend/shared
    env_file:
      - ./you-app-backend/user-microservice/.env
    depends_on:
      - mongo

  mongo:
    container_name: mongo
    image: mongo:latest
    ports:
      - "27017:27017"
    restart: on-failure:5
    volumes:
      - mongo-data:/data/db

  rabbitmq:
    container_name: rabbitmq
    image: rabbitmq:latest
    ports:
      - "5673:5672"
      - "15673:15672"
    restart: on-failure:5

volumes:
  mongo-data:


Solution

  • Your issue is related to the dockerfile paths provided for the microservice containers. You're already passing in a context and dockerfile is relative to context as mentioned in the docs.

    Replace each dockerfile in the docker-compose.dev.yml file to Dockerfile.dev, for example:

      chat-service:
        build:
          context: ./you-app-backend/chat-microservice
          dockerfile: Dockerfile.dev
        container_name: chat-microservice