I have a command that calls a local docker container server.
I use docker-compose run name_of_service /bin/bash to exec into an image and from there calling command below works as expected.
pip install --trusted-host pypi --extra-index-url http://pypi:8000 -r requirements.txt
But running virtually the same command in Dockerfile results in a Retrying error
RUN pip install --trusted-host pypi --extra-index-url http://pypi:8000 -r requirements.txt --user
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x7f54bac2dad0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /custom-utils/
Both services are in one docker-compose.yml
Yaml
  service:
    image: service:20.10.1
    build:
      context: platform
      dockerfile: service/Dockerfile
    depends_on:
      - api
      - pypi
    environment:
      PORT: "8088"
    ports:
      - "8088:8088"
    volumes:
      - some_location_of_source
    restart: always
  pypi:
    image: pypi:20.10.1
    build:
      context: services/pypi
      dockerfile: Dockerfile
    environment:
      PORT: "8000"
    expose:
      - "8000"
    ports:
      - "8000:8000"
    volumes:
      - some_location_of_source
 
    