解决报错ERROR: Service 'web' failed to build: Get https://registry-1.docker.io/v2/library/python/manifests/2.7: net/http: TLS handshake timeout
一、问题描述
当我用docker-compose up时,因为需要build Dockerfile文件,出现下面这个错误:
ERROR: Service 'web' failed to build: Get https://registry-1.docker.io/v2/library/python/manifests/2.7: net/http: TLS handshake timeout
二、问题解决
1、查看可用的ip地址
[root@docker-node1 compose-flask]# dig @114.114.114.114 registry-1.docker.io ; <<>> DiG 9.9.4-RedHat-9.9.4-37.el7 <<>> @114.114.114.114 registry-1.docker.io ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38727 ;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;registry-1.docker.io. IN A ;; ANSWER SECTION: registry-1.docker.io. 32 IN A 34.199.40.84 registry-1.docker.io. 32 IN A 34.201.196.144 registry-1.docker.io. 32 IN A 34.228.211.243 registry-1.docker.io. 32 IN A 34.232.31.24 registry-1.docker.io. 32 IN A 52.55.198.220 registry-1.docker.io. 32 IN A 52.202.253.107 registry-1.docker.io. 32 IN A 52.201.142.14 registry-1.docker.io. 32 IN A 34.199.77.19 ;; Query time: 49 msec ;; SERVER: 114.114.114.114#53(114.114.114.114) ;; WHEN: 二 2月 04 14:15:50 CST 2020 ;; MSG SIZE rcvd: 177
通过dig @114.114.114.114 registry-1.docker.io命令查看所有的可用地址。
2、修改/etc/hosts文件
可以将上述可用的ip以下面这种方式写入:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #写入可用的ip 34.199.40.84 registry-1.docker.io 34.201.196.144 registry-1.docker.io
然后进行文件保存,重新执行docker-compose up命令,问题解决。
作者:iveBoy
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。