• 执行docker run命令时报错Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)


    一.解决办法: 修改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

  • 相关阅读:
    浮点数如何存储与表示(精度问题)
    快速幂详解(幂运算与矩阵)
    斐波那契数列的四种解法(头递归、尾递归、迭代与矩阵快速幂)
    机器码与位运算
    pytorch中参数dim的含义(正负,零,不传)
    查看显卡名称 pytorch
    使用国内源快速下载Python包(以matplotlib为例)
    基于Attention的机器翻译模型(Visualizing A Neural Machine Translation Model)
    GNU Parallel-安装+使用
    统计文件个数、删除空文件等Linux命令
  • 原文地址:https://www.cnblogs.com/dakewei/p/10831125.html
Copyright © 2020-2023  润新知