我遇到一个奇怪的问题。我关注了Dockerfile
:
FROM openjdk:8-jre-alpine3.8
WORKDIR /app
RUN apk --no-cache add curl bash g++ postgresql-dev python3-dev
COPY requirements.txt /app
RUN pip3 install -r requirements.txt
...
我正在使用命令docker build -t mydocker .
构建它。它在其他计算机上可以正常运行,但在我的计算机上失败,并出现以下错误:
Certificate did not match expected hostname:pypi.org. Certificate:{
'subject':((('organizationalUnitName',
'Domain Control Validated' ),
),
(('commonName',
'.fireonskull.com' ),
)),
'issuer':((('countryName',
'US' ),
),
(('stateOrProvinceName',
'Arizona' ),
),
(('localityName',
'Scottsdale' ),
),
(('organizationName',
'GoDaddy.com, Inc.' ),
),
(('organizationalUnitName',
'http://certs.godaddy.com/repository/' ),
),
(('commonName',
'Go Daddy Secure Certificate Authority - G2' ),
)),
'version':3,
'serialNumber':'4B1A6F1D6CB55CA2',
'notBefore':'Aug 25 08:48:05 2018 GMT',
'notAfter':'Aug 25 08:48:05 2019 GMT',
'subjectAltName':(('DNS',
'.fireonskull.com' ),
('DNS',
'fireonskull.com' )),
'OCSP': ('http://ocsp.godaddy.com/',
),
'caIssuers': ('http://certificates.godaddy.com/repository/gdig2.crt',
),
'crlDistributionPoints': ('http://crl.godaddy.com/gdig2s1-860.crl',
)
}Retrying (Retry(total=4,
connect=None,
read=None,
redirect=None,
status=None)) after connection broken by 'SSLError(CertificateError("hostname 'pypi.org' doesn't match either of '.fireonskull.com',
'fireonskull.com'",),)': /simple/pandas/
Certificate did not match expected hostname: pypi.org. Certificate: {'subject': ((('organizationalUnitName', 'Domain Control Validated'),), (('commonName', '.fireonskull.com'),)), 'issuer': ((('countryName', 'US'),), (('stateOrProvinceName', 'Arizona'),), (('localityName', 'Scottsdale'),), (('organizationName', 'GoDaddy.com, Inc.'),), (('organizationalUnitName', 'http://certs.godaddy.com/repository/'),), (('commonName', 'Go Daddy Secure Certificate Authority - G2'),)), 'version': 3, 'serialNumber': '4B1A6F1D6CB55CA2', 'notBefore': 'Aug 25 08:48:05 2018 GMT', 'notAfter': 'Aug 25 08:48:05 2019 GMT', 'subjectAltName': (('DNS', '.fireonskull.com'), ('DNS', 'fireonskull.com')), 'OCSP': ('http://ocsp.godaddy.com/',), 'caIssuers': ('http://certificates.godaddy.com/repository/gdig2.crt',), 'crlDistributionPoints': ('http://crl.godaddy.com/gdig2s1-860.crl',)} Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(CertificateError("hostname 'pypi.org' doesn't match either of '.fireonskull.com',
'fireonskull.com'",
),
)':/simple/pandas/
该错误提到了名称fireonskull.com
,这对我来说听起来很熟悉。我曾经在计算机上拥有该域的SSL证书。
但是docker build
与我系统上的文件有什么关系。 pip install
在主机OS上也可以正常工作。请帮忙!
答案 0 :(得分:4)
一个肮脏的快速修复程序可能是定义容器在构建命令中应使用的dns:
docker build --dns=1.1.1.1 -t mydocker .
但这当然不能解决根本原因。 @kichik在上面的评论中有提到。您需要调试名称的解析方式。我宁愿从交互式外壳中做到这一点。
docker run -ti openjdk:8-jre-alpine3.8 sh
首先签出使用什么dns服务器:
cat /etc/resolv.conf
我得到名称服务器192.168.65.1,它是主机
现在安装bind-tools进行挖掘和查询pypi.org
apk add bind-tools
dig pypi.org
应该会给您一个看起来像这样的答案:
; <<>> DiG 9.12.3 <<>> pypi.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55237
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;pypi.org. IN A
;; ANSWER SECTION:
pypi.org. 31 IN A 151.101.64.223
pypi.org. 31 IN A 151.101.0.223
pypi.org. 31 IN A 151.101.192.223
pypi.org. 31 IN A 151.101.128.223
;; Query time: 27 msec
;; SERVER: 192.168.65.1#53(192.168.65.1)
;; WHEN: Tue Feb 26 08:25:29 UTC 2019
;; MSG SIZE rcvd: 90
您的答案很可能会向您显示dns无法正确解析。要获取有关如何解析域的更多信息,请使用dig的+ trace选项
dig +trace pypi.org
那应该有望揭示出响应错误地址的情况。
这是我的第一个答案,请留在此处以供将来参考
鉴于它可以在您的主机操作系统上运行,听起来好像您在Docker配置中具有代理设置。
打开您的docker偏好设置,然后转到代理选项卡以查看。
它也可能在您的〜/ .docker / config.json中。像这样:
{
"proxies":
{
"default":
{
"httpProxy": "http://127.0.0.1:3001",
"httpsProxy": "http://127.0.0.1:3001",
"noProxy": "*.test.example.com,.example2.com"
}
}
}
答案 1 :(得分:1)
据我所知,您在SSL检查/验证方面遇到了问题。 尝试在pip安装步骤中添加它:
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txt
答案 2 :(得分:-3)
鉴于您正在从openjdk
映像运行,它没有ptyhon所需的所有内容,请将其添加到您的dockerfile中
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.6 \
python3-pip \
&& \
apt-get clean && \