Docker防火墙pip安装错误

时间:2021-07-03 01:03:07

标签: python docker pip proxy

我一直在尝试构建一个简单的 docker 映像,但是我在公司防火墙后面。我已经尝试了以下所有步骤,但没有任何效果。

尝试 1: 如果我没有设置代理,但 Docker 桌面 -> 资源 -> 使用我的地址和端口设置代理并运行

docker build -t python-imdb .

我明白了:

 => => # WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTi
 => => # meoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f71033cb730>, 'Connection to pypi.org timed out. (con
 => => # nect timeout=15)')': /simple/pyqt5/

4 次然后停止,找不到满足 pyqt5 要求的版本

尝试 2: 如果我没有设置代理,但 Docker 桌面 -> 资源 -> 代理设置与我的地址和端口并运行 docker build --build-arg HTTP_PROXY=address:port --build-arg HTTPS_PROXY=address:port -t python-imdb .

我明白了:

#8 8.972 WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f57bc6055e0>: Failed to establish a new connection: [Errno 111] Connection refused'))': /simple/pyqt5/
#8 8.985 ERROR: Could not find a version that satisfies the requirement pyqt5 (from versions: none)
#8 8.985 ERROR: No matching distribution found for pyqt5

尝试 3: 如果我没有设置代理,但 Docker 桌面 -> 资源 -> 代理设置与我的地址和端口并运行 docker build --build-arg HTTP_PROXY=address:port -t python-imdb .

我明白了:

 => => # WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTi
 => => # meoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f0d31f56100>, 'Connection to pypi.org timed out. (con
 => => # nect timeout=15)')': /simple/pyqt5/

我明白了:

#8 8.972 WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f57bc6055e0>: Failed to establish a new connection: [Errno 111] Connection refused'))': /simple/pyqt5/
#8 8.985 ERROR: Could not find a version that satisfies the requirement pyqt5 (from versions: none)
#8 8.985 ERROR: No matching distribution found for pyqt5

尝试 4: 将 docker 文件更新为: 所以我的 Dockerfile 包含:

FROM python:3.9

ENV HTTP_PROXY = "address:port"

ENV HTTPS_PROXY = "address:port"

ADD main.py .

RUN pip install pyqt5

CMD ["python", "./main.py"]

并运行 docker build -t python-imdb 。

我明白了:

#7 8.965 WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f787844faf0>: Failed to establish a new connection: [Errno 111] Connection refused'))': /simple/pyqt5/
#7 8.986 ERROR: Could not find a version that satisfies the requirement pyqt5 (from versions: none)
#7 8.986 ERROR: No matching distribution found for pyqt5

1 个答案:

答案 0 :(得分:0)

如果代理在您的机器上正确配置,它应该可以用于:

docker build --network=host -t python-imdb .

如果它不起作用,请使用 cntlmpx 向代理进行身份验证。