尝试在RUN pip install -r requirements.txt
步骤构建Docker映像失败,并出现以下错误:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/asgiref/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/asgiref/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/asgiref/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/asgiref/`
由于某种原因,asgiref==3.5.2
不想安装。这可能是什么原因?
使用的系统:
- 操作系统:Windows 11
- WSL 2,板载Ubuntu 22.04
- Docker版本20.10.19,内部版本号d85ef84
- 停靠文件内容:
# Pull base image
FROM python:3.10.6-slim-bullseye
# Set enviroment variables
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set work directory
WORKDIR /code
# Install dependencies
COPY ./requirements.txt .
RUN pip install -r requirements.txt
# Copy project
COPY . .
- 要求. txt内容:
asgiref==3.5.2
Django==4.1.2
sqlparse==0.4.3
2条答案
按热度按时间vybvopom1#
我今天遇到了这个问题。所以,你可以在你的Docker构建线中用一个
--network host
来修复这个问题。出现此问题的原因是网络接口的MTU不匹配。如果以交互模式从Dockerfile打开基本映像:
sudo docker run -it {your base image repo} /bin/bash
,并运行ip a
,然后在您的主机操作系统上执行相同的操作,您可能会发现它们是不同的。这意味着Docker网桥正在丢弃数据包/传输失败。如果您希望网桥网络工作,而不是主机,请在您的主机操作系统上的/etc/docker/daemon.json
处创建一个文件,其中包含然后运行
sudo systemctl restart docker
,这可能会修复您桥接网络。编辑:我应该补充的是,只有当你的容器有互联网连接时(最有可能),才会出现这种情况(IidoE. apt/yum工作正常,但其他东西如pip中断)。如果你无法拉取任何东西,你可能有DNS/防火墙问题。
pgccezyw2#
看起来主要的问题是,我安装了docker的权利,从我的WSL 2 ubuntu发行版使用说明的Linux,而不是与官方的Windows安装程序,它无缝集成与WSL 2的帮助。重新安装,现在网络工作的预期。谢谢大家!