简体   繁体   English

Docker compose 没有 inte.net 访问权限

[英]Docker compose has no internet access

Docker compose failed to build. Docker compose 构建失败。 There is no problem with pulling images, but fails due timeout when trying to run command like "RUN pip install pipenv".拉取图像没有问题,但在尝试运行“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.只有将 .network: host" 添加到 docker-compose.yml 中才能构建。无论如何,它不能解决我的问题,因为任何发送 GET 请求的尝试都会因超时而失败。不知道该怎么做。同样的问题发生在 Ubuntu 22 和 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:您可以使用已定义的 su.net 创建一个 custom.network:

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.试试这个,我希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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