V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
raysonx
V2EX  ›  程序员

解决`docker pull`被 reset 的问题

  •  
  •   raysonx ·
    vfreex · 2017-03-07 11:08:53 +08:00 · 8980 次点击
    这是一个创建于 2578 天前的主题,其中的信息可能已经有所发展或是发生改变。

    例如:

    $ docker pull ubuntu:16.04
    Trying to pull repository docker.io/library/ubuntu ... 
    Get https://registry-1.docker.io/v2/library/ubuntu/manifests/sha256:dd7808d8792c9841d0b460122f1acf0a2dd1f56404f8d1e56298048885e45535: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fubuntu%3Apull&service=registry.docker.io: read tcp *.*.*.*:41348->50.17.62.194:443: read: connection reset by peer
    

    原因: 目测 50.17.62.194 被 TCP RESET 。

    解决方法:

    1. 找到其它可用 IP :
    $ dig auth.docker.io
    
    ; <<>> DiG 9.10.4-P6-RedHat-9.10.4-4.P6.fc25 <<>> auth.docker.io
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7119
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 4096
    ;; QUESTION SECTION:
    ;auth.docker.io.			IN	A
    
    ;; ANSWER SECTION:
    auth.docker.io.		60	IN	A	34.193.147.40
    auth.docker.io.		60	IN	A	50.17.62.194
    auth.docker.io.		60	IN	A	52.5.246.212
    
    ;; Query time: 130 msec
    ;; SERVER: *.*.*.*#53(.*.*.*.*)
    ;; WHEN: Tue Mar 07 11:03:29 CST 2017
    ;; MSG SIZE  rcvd: 91
    
    1. /etc/hosts强制 docker.io 相关的域名解析到其它可用 IP :
    # /etc/hosts
    34.193.147.40 registry-1.docker.io auth.docker.io
    
    7 条回复    2017-03-07 16:35:32 +08:00
    joshz
        1
    joshz  
       2017-03-07 11:22:58 +08:00 via Android
    registry 在国内连接总是各种问题,不知道是不是墙在作梗,先 mark 下
    knightdf
        2
    knightdf  
       2017-03-07 11:29:27 +08:00
    在墙内, 10 次 pull8 次 timeout2 次 reset
    viila
        3
    viila  
       2017-03-07 12:27:27 +08:00
    ss -> polipo -> HTTPS_PROXY
    or 自建海外 registry 私用 + tag / dns 强制解析
    or 国内海量的 registry-mirror ,高校的比如 tuna 或者 ustc ,不过 gcr.io 好像没找到替代的。
    cloverstd
        4
    cloverstd  
       2017-03-07 12:32:41 +08:00   ❤️ 1
    zgqq
        5
    zgqq  
       2017-03-07 13:25:46 +08:00
    @knightdf 我这边翻墙也是一样的
    Eleutherios
        6
    Eleutherios  
       2017-03-07 14:41:32 +08:00
    HTTP_PROXY=socks5://localhost:5000 docker pull ~~~

    ref: https://github.com/docker/docker/issues/5989
    gwind
        7
    gwind  
       2017-03-07 16:35:32 +08:00
    https://www.daocloud.io/mirror
    或自己 vps 搭建 docker cache registry
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1667 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:46 · PVG 00:46 · LAX 09:46 · JFK 12:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.