1. 程式人生 > >Ubuntu16.04下Docker pull connection refused 解決辦法

Ubuntu16.04下Docker pull connection refused 解決辦法

檢查Ubuntu是否設定了DNS,確保解析正常

Ubuntu DNS配置方法

interfaces方式
修改/etc/network/interfaces,配置DNS需要在該檔案中加入

dns-nameserver xx.xx.xx.xx
dns-nameserver xxx.xxx.xx.xx
dns-nameservers xxx.xxx.xxx.xxx xxx.xxx.xx.xxx

•dns-nameserver: 指定一條DNS地址,如果需要指定多個DNS則需要使用新增多行。
•dns-nameservers: 指定多個DNS地址,用空格隔開。
需要重啟電腦方可生效

resolvconf方式


修改DNS則是通過修改/etc/resolvconf/resolv.conf.d/base,在檔案中加入

nameserver xxx.xxx.xx.xxx
nameserver xx.xx.xx.xx

•nameserver: 指定DNS地址,當有多個DNS記錄時每個DNS記錄佔一行。

sudo resolvconf -u      #更新/etc/resolv.conf檔案

Ubuntu 更換國內源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak1

更換源為阿里源

sudo gedit /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.aliyun
.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

更新源

sudo apt-get update

這時候你會發現docker pull正常了~