问题:docker 无法run远程库
[root@localhost docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
解决方案:
用vi打开/etc/resolv.conf
vi resolv.conf
将 nameserver 改成 8.8.8.8
# Generated by NetworkManager
search localdomain
#nameserver 192.168.231.2
nameserver 8.8.8.8
然后重启docker
sudo systemctl restart docker
run 成功
[root@localhost etc]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
还需要注意的是机器重启之后,上面设置会失效,重启服务器DNS就会被强制还原
需要在网卡设置中修改NM_CONTROLLED的值
在/etc/sysconfig/network-scripts/ifcfg-eth33中修改内容:
NM_CONTROLLED="no" //是否允许Network Manager管理,设置为no
在同一文件中设置
PEERDNS="yes"
DNS1="xxx.xxx.xxx.xxx"
DNS2="xxx.xxx.xxx.xxx"
修改完毕之后重启网卡:
service network restart
参考链接:Error response from daemon: Get https://registry-1.docker.io/v2/: Docker报错解决方案
详解CentOS重启后resolv.conf被重置的解决方案