在使用 docker 构建 django cms 应用时,出现了以下的错误信息:
$ git clone git@github.com:django-cms/django-cms-quickstart.git
$ cd django-cms-quickstart
$ docker compose build web
.....
=> ERROR [4/5] RUN pip install -r requirements.txt 93.5s
------
> [4/5] RUN pip install -r requirements.txt:
#0 8.385 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/asgiref/
#0 13.94 WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/asgiref/
#0 20.00 WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/asgiref/
#0 30.52 Collecting asgiref==3.5.2
#0 36.61 Downloading asgiref-3.5.2-py3-none-any.whl (22 kB)
#0 88.27 ERROR: Could not find a version that satisfies the requirement boto3==1.14.49 (from versions: none)
#0 88.27 ERROR: No matching distribution found for boto3==1.14.49
------
failed to solve: executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1
关键的错误信息,是 pip install 时报错: connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))'
这样的错误信息,如果是在操作系统下使用 pip install 时发生,我们通过配置修改 pip 源即可解决:
> pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
对于上面 docker 编译时出现的问题, 我们通过直接修改 Dockerfile 中的 pip install 指令来进行换源
RUN pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/