简体   繁体   中英

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 pypi.org timed out. (connect timeout=15)')': /simple/pip/

request error:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='google.com', 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'))

You may create a custom.network with a defined su.net:

version: '3'
services:
  web:
    build:
      context: .
      network: custom_network

networks:
  custom_network:
    ipam:
      driver: default
      config:
        - subnet: "192.168.100.1/28"

Try this out, I hope this will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM