描述:执行docker run -d nginx:latest或docker pull mysql命令失败
报错信息如下:
[root@node01 ~]# docker run -d nginx:latest
Unable to find image ‘nginx:latest’ locally
docker: Error response from daemon: Head “https://registry-1.docker.io/v2/library/nginx/manifests/latest”: dial tcp: lookup registry-1.docker.io on 192.168.1.1:53: no such host.
See ‘docker run –help’.
解决办法:
1) 配置静态IP
[root@node01 ~]#vim /etc/sysconfig/network-scripts/ifcfg-ens33
将BOOTPROTO=”dhcp”
改为
BOOTPROTO=”static”
添加如下配置:
IPADDR=”192.168.16.129″
NETMASK=”255.255.255.0″
DNS1=”8.8.8.8″
DNS2=”8.8.4.4″
GATEWAY=”192.168.16.2″
2)修改resolv.conf
[root@node01 ~]# vim /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.4.4
3)添加国内镜像
vim /etc/docker/daemon.json
添加如下内容:
{
“registry-mirrors”: [“https://s27w6kze.mirror.aliyuncs.com”]
}
4)重启docker
systemctl daemon-reload
systemctl restart docker