docker 构建python程序报错
Step 7/10 : RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn --default-timeout=20 --no-cache-dir -r requirements.txt
---> Running in 2fe1512d82e8
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
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 0x7fa7b89c4160>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/certifi/
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 0x7fa7b8618c10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/certifi/
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 0x7fa7b867da90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/certifi/
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 0x7fa7b867da00>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/certifi/
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 0x7fa7b867d970>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/certifi/
ERROR: Could not find a version that satisfies the requirement certifi==2022.6.15 (from versions: none)
ERROR: No matching distribution found for certifi==2022.6.15
本次测试、另一台服务器测试没问题。公司通过虚拟镜像搞的服务器出现问题,怀疑是配置
查看linux本身环境dns配置
cat /etc/resolv.conf
nameserver 218.1.23.333
进入/etc/docker/下
cd /etc/docker
修改daemon.json文件(增加dns配置)如下
{
"insecure-registries": ["218.1.23.333:8089"],
"registry-mirrors": ["https://4xtasccp.mirror.aliyuncs.com"],
"dns":["218.1.23.333"]
}
重新加载配置文件
systemctl daemon-reload
重启docker生效
systemctl restart docker
重新构建python镜像
完成
补充docker daemon.json配置相关说明
{
"api-cors-header": "",
"authorization-plugins": [],
"bip": "",
"bridge": "",
"cgroup-parent": "",
"cluster-store": "",
"cluster-store-opts": {},
"cluster-advertise": "",
"debug": true,
"default-gateway": "",
"default-gateway-v6": "",
"default-runtime": "runc",
"default-ulimits": {},
"disable-legacy-registry": false,
"dns": [
"192.168.1.1"
],
"dns-opts": [],
"dns-search": [],
"exec-opts": [],
"exec-root": "",
"fixed-cidr": "",
"fixed-cidr-v6": "",
"graph": "/var/lib/docker",
"data-root": "/var/lib/docker",
"group": "",
"hosts": [],
"icc": false,
"insecure-registries": [],
"ip": "0.0.0.0",
"iptables": false,
"ipv6": false,
"ip-forward": false,
"ip-masq": false,
"labels": [
"nodeName=node-121"
],
"live-restore": true,
"log-driver": "",
"log-level": "",
"log-opts": {},
"max-concurrent-downloads": 3,
"max-concurrent-uploads": 5,
"mtu": 0,
"oom-score-adjust": -500,
"pidfile": "",
"raw-logs": false,
"registry-mirrors": [
"xxxx"
],
"runtimes": {
"runc": {
"path": "runc"
},
"custom": {
"path": "/usr/local/bin/my-runc-replacement",
"runtimeArgs": [
"--debug"
]
}
},
"selinux-enabled": false,
"storage-driver": "",
"storage-opts": [],
"swarm-default-advertise-addr": "",
"tls": true,
"tlscacert": "",
"tlscert": "",
"tlskey": "",
"tlsverify": true,
"userland-proxy": false,
"userns-remap": ""
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)