先说结论:pip版本不对,在这个项目里面必须pip3 install pip==20.1的版本才行,其他情况因人而异,可以参考我的试试,下面是摸索的过程
使用该命令安装requirements文件
docker build -t ubuntu_flask:1.3 . -f Dockerfile_1.3
这是Dockerfile_1.3:
FROM ubuntu_flask:1.22
# 复制文件到容器
ADD requirements.txt /home
# 跳转到指定目录
WORKDIR /home
RUN pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
注意,在requirements文件中没有写 setuptools==46.1.3和wheel==0.34.2
arrow==0.17.0
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
Flask==1.1.2
Flask-Sockets==0.2.1
gevent==1.5.0
gevent-websocket==0.10.1
greenlet==0.4.17
idna==2.8
iso8601==0.1.13
itsdangerous==1.1.0
Jinja2==2.11.2
leancloud==2.8.1
MarkupSafe==1.1.1
python-dateutil==2.8.1
qiniu==7.2.2
requests==2.22.0
retrying==1.3.3
secure-cookie==0.1.0
six==1.15.0
urllib3==1.25.3
Werkzeug==1.0.1
zope.event==4.5.0
zope.interface==5.2.0
这样安装后命令行卡在下面这行就不动了
Building wheels for collected packages: gevent, qiniu, retrying, cffi
然后显示安装失败
#8 90.35 Running setup.py bdist_wheel for cffi: finished with status 'error' #8 90.35 Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ucjorr8s/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmprgg3m7jlpip-wheel- --python-tag cp35:
。。。。。。。。。。。。。。。。。。。。
#8 99.89 ----------------------------------------
#8 99.95 Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-47on810j/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-z4_zgy1t-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-47on810j/cffi/
#8 105.4 You are using pip version 8.1.1, however version 23.0.1 is available.
#8 105.4 You should consider upgrading via the 'pip install --upgrade pip' command.
------
executor failed running [/bin/sh -c pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple]: exit code: 1
在进行网上资料查阅后,提醒我没有安装这两个模块
setuptools==46.1.3
wheel==0.34.2
然后将这两个添加到requirements中
运行后依旧报上面的错误,报错中提示我pip版本太旧,于是我将版本更新到pip==20.1
再次运行命令,最后成功解决
查看镜像中也有1.3的镜像了
解决途中多次想放弃,最后终于解决了
最后通过多次验证,发现没有setuptools==46.1.3和wheel==0.34.2的情况下,只更新pip版本,也能安装成功,大家可以多试试