Docker mutiple port issue

Hi,

I am currently working on two inter related ASP.NET Core WebAPI services (Service1 & Service2) in a solution. Both are having docker files and Exposing port 80.

Service1 is an independent service and required to be called from Service2. I have given both docker-compose.yml and docker-compose.override.yml.

docker-compose.yml

version: '3.4'

services:
  services1:
    image: ${DOCKER_REGISTRY-}services1
    network_mode: bridge
    build:
      context: .
      dockerfile: Services1/Dockerfile
    ports:
     - "501:80"
     
  services1:
    image: ${DOCKER_REGISTRY-}services2
    network_mode: bridge
    build:
      context: .
      Services2/Dockerfile
    ports:
     - "502:80"

docker-compose.override.yml

version: '3.4'

services:
  services1:
    build:
      context: .
      dockerfile: Services1/Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "1001:80"

  services2:
    build:
      context: .
      Services2/Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - SERVICE1=http://localhost:1001
      ports:
      - "1002:80"	 

When i call Service1(localhost:1001) from Service2(localhost:1002) with network_mode: bridge, I am getting the below exception.

{System.Net.Http.HttpRequestException: Cannot assign requested address —> System.Net.Sockets.SocketException: Cannot assign requested address

when i change the network_mode to host ( network_mode:host ), i am getting the below exception.

System.IO.IOException: ‘Failed to bind to address http://[::]:80: address already in use.’

So please let me know how to resolve the issue.