Search code examples
node.jsdockerdocker-composenestjs

Docker serve NestJs on local network


I'm coding with NestJS and using Docker, I can't configure my own docker-compose file to serve on the local network card with IP 192.168.1.7.

i saw this link before.

Docker subnet: 192.168.65.0

networks:
  host:
    name: mamanpaz
    external: true
  lan_access:
    driver: bridge

services:
  application:
    build:
      context: .
      dockerfile: apps/application/Dockerfile
      target: development
    command: npm run start:dev application
    env_file:
      - apps/application/.env
    depends_on:
      - rabbitmq
      - register
    volumes:
      - .:/usr/src/app
      - /usr/src/app/node_modules
    networks:
      - default
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - '3000:3000'

docker network ls command output

NETWORK ID     NAME                  DRIVER    SCOPE
2b6d6312d176   bridge                bridge    local
a776b0af5ba3   host                  host      local
b152fd5400db   mamanpaz_default      bridge    local
4b401d652fb2   my-network            bridge    local
6476cf7a691a   none                  null      local

Solution

  • Enabling Debian distribute via Settings->Resources -> WSL integration in Docker Desktop solved my problem