执行docker run命令时报错Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for ...

一.解决办法: 修改host

二.步骤如下

  2.1 安装dig工具

     sudo apt-get install dnsutils -y (ubuntu下的安装方法)

  2.2 找到registry-1.docker.io对应的ip地址    

    jello$ dig @8.8.8.8 registry-1.docker.io

    ; <<>> DiG 8.8 hello <<>> @8.8.8.8 registry-1.docker.io
    ; (1 server found)
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6620
    ;; 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. 40 IN A 34.201.236.93
    registry-1.docker.io. 40 IN A 34.206.236.31
    registry-1.docker.io. 40 IN A 34.233.151.211
    registry-1.docker.io. 40 IN A 34.228.211.243
    registry-1.docker.io. 40 IN A 52.22.67.152
    registry-1.docker.io. 40 IN A 34.201.196.144
    registry-1.docker.io. 40 IN A 52.22.201.61
    registry-1.docker.io. 40 IN A 34.232.31.24

    ;; Query time: 162 msec
    ;; SERVER: 8.8.8.8#53(8.8.8.8)
    ;; WHEN: Mon August 8 8:8:8 CST 2018
    ;; MSG SIZE rcvd: 177

  2.3 修改hosts表

    echo 34.233.151.211 registry-1.docker.io > /etc/hosts

补充:

  方法二:添加dns 8.8.8.8

    a 将nameserver 8.8.8.8写入/etc/resolvconf/resolv.conf.d/head文件中

      sudo vi /etc/resolvconf/resolv.conf.d/head

    b 更新dns

      sudo resolvconf -u

  方法三:修改镜像源

    a sudo vi /etc/docker/daemon.json

      写入以下内容:     

{
    "registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]
}

 

    b 重新加载docker的配置文件

      sudo systemctl daemon-reload

    c 重启docker

      sudo systemctl restart docker

转载于:https://www.cnblogs.com/dakewei/p/10831125.html

你可能感兴趣的:(执行docker run命令时报错Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for ...)