解决dockerfile创建镜像时pip install报错的bug

项目场景:

使用docker-compose创建django容器


问题描述

python 复制代码
 > [5/5] RUN /bin/bash -c 'source ~/.bashrc && python3 -m pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple':              
0.954 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple                                                                                   
15.98 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fefee58f1d0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/aliyun-python-sdk-core/                                                                                                                        
31.50 WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fefea3e8d10>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/aliyun-python-sdk-core/
47.53 WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fefea3e9710>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/aliyun-python-sdk-core/
64.55 WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fefea3e9f50>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/aliyun-python-sdk-core/
83.57 WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fefea3ea8d0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/aliyun-python-sdk-core/
98.59 ERROR: Could not find a version that satisfies the requirement aliyun-python-sdk-core (from versions: none)
98.59 ERROR: No matching distribution found for aliyun-python-sdk-core
113.6 WARNING: There was an error checking the latest version of pip.

解决dockerfile创建镜像时pip install报错的bug


解决方案:

执行service docker restart

相关推荐
tryCbest4 天前
Windows环境下配置pip镜像源
windows·pip
百锦再4 天前
Django实现接口token检测的实现方案
数据库·python·django·sqlite·flask·fastapi·pip
ALGO阿狗4 天前
SimpleDateFormat(“YYYY-MM-dd“)格式化时间出现了bug?
bug
coding者在努力5 天前
LangChain之解析器核心组件.2026年新版讲解,超详细
windows·python·机器学习·langchain·pip
爱学习的小可爱卢5 天前
JavaSE基础-Java异常体系:Bug定位终极指南
java·bug·javase
GeekyGuru5 天前
代码诊疗室——疑难Bug破解战
bug
wumingxiaoyao6 天前
从 requirements.txt 到 uv:多模块 Monorepo 的依赖管理升级指南(用法、特点、区别与最佳实践 + 例子)
pip·uv·pip tool
嵌入式×边缘AI:打怪升级日志8 天前
9.2.3 UART 驱动严重 Bug(保姆级讲解)
bug
qq_242188633210 天前
代码诊疗室——疑难Bug破解战
bug
Moshow郑锴12 天前
Java SpringBoot 疑难 Bug 排查思路解析:从“语法正确”到“行为相符”
java·spring boot·bug