我支持一个企业网络,目前可以通过两种方式从Python
安装Dockerfile
包。
(1)引用证书
RUN pip3 install --cert=/usr/local/share/ca-certificates/zscaler-root.crt <SOME-PYTHON-PACKAGE>
(2)通过向受信任的主机添加repos/URL
RUN touch /etc/pip.conf
RUN echo "[global] \n trusted-host = pypi.python.org pypi.org files.pythonhosted.org" >> /etc/pip.conf
RUN pip3 install <SOME-PYTHON-PACKAGE>
与选项2不同,我更愿意在全球范围内设置证书。
RUN touch /etc/pip.conf
RUN echo "[global] \n cert=/usr/local/share/ca-certificates/zscaler-root.crt" >> /etc/pip.conf
但这行不通。
结果为SSLError(SSLCertVerificationError )。
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)'))': /simple/flask/
为什么选项1可以引用cert,但是将它添加到全局配置文件却失败了?
编辑:
按照per @phd的建议,他尝试了以下方法。
RUN pip3 config --global set global.cert /usr/local/share/ca-certificates/zscaler-root.crt
RUN pip3 config set global.cert /usr/local/share/ca-certificates/zscaler-root.crt
但是没有joy。
还尝试将SSL_CERT_DIR
设置为https://stackoverflow.com/a/24353642/6265370。
ENV SSL_CERT_DIR="/usr/local/share/ca-certificates/"
再说一次没有雪茄。
这里有更多的信息
pip 21.1.2 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
pip3 config list -v
For variant 'global', will try loading '/etc/xdg/pip/pip.conf'
For variant 'global', will try loading '/etc/pip.conf'
For variant 'user', will try loading '/root/.pip/pip.conf'
For variant 'user', will try loading '/root/.config/pip/pip.conf'
For variant 'site', will try loading '/usr/local/pip.conf'
https://stackoverflow.com/questions/68180379
复制相似问题