Docker compose has no internet access

Docker compose failed to build. There is no problem with pulling images, but fails due timeout when trying to run command like “RUN pip install pipenv”. Build is possible only with adding “network: host” into docker-compose.yml. Anyway it isn’t solves my problem because any atempt to send GET request fails with timeout. No idea what to do. The same problem occurs at Ubuntu 22 and Manjaro 21.

build error:

 => [6/9] RUN pip install --upgrade pip                                                                                                                                       85.7s
 => => # Requirement already satisfied: pip in /usr/local/lib/python3.9/site-packages (22.0.4)                                                                                     
 => => # WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HT
 => => # TPSConnection object at 0x7f3f75f13340>, 'Connection to timed out. (connect timeout=15)')': /simple/pip/

request error:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fccaa7afdc0>: Failed to establish a new connection: [Errno 110] Connection timed out'))