Mac环境下Minikube无法拉取镜像问题求助
问题:Minikube容器无法拉取镜像,内部DNS解析失败
环境信息
- macOS 13.5
- Minikube(Docker作为容器运行时)
- 已完成Minikube和kubectl基础配置
错误现象
- Pod状态异常:
$ kubectl get pod NAME READY STATUS RESTARTS AGE nginx-depl-6b7698588c-2j7wt 0/1 ImagePullBackOff 0 6m51s
- Pod事件详情:
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 21s default-scheduler Successfully assigned default/nginx-depl-6b7698588c-2j7wt to minikube Warning Failed 19s kubelet Failed to pull image "nginx": rpc error: code = Unknown desc = Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on 192.xxx.xx.x:53: read udp 192.xxx.xx.x:54231->192.xxx.xx.x:53: read: connection refused Normal BackOff 17s (x2 over 18s) kubelet Back-off pulling image "nginx" Warning Failed 17s (x2 over 18s) kubelet Error: ImagePullBackOff Normal Pulling 6s (x2 over 19s) kubelet Pulling image "nginx" Warning Failed 6s (x2 over 19s) kubelet Error: ErrImagePull Warning Failed 6s kubelet Failed to pull image "nginx": rpc error: code = Unknown desc = Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on 192.xxx.xx.x:53: read udp 192.xxx.xx.x:47743->192.xxx.xx.x:53: read: connection refused
- Minikube内部DNS解析失败:
$ minikube ssh _ _ _ _ ( ) ( ) ___ ___ (_) ___ (_)| |/') _ _ | |_ __ /' _ ` _ `\| |/' _ `\| || , < ( ) ( )| '_`\ /'__`\ | ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )( ___/ (_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____) $ ping google.com ping: bad address 'google.com' $ cat /etc/resolv.conf # This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8). # Do not edit. # # This file might be symlinked as /etc/resolv.conf. If you're looking at # /etc/resolv.conf and seeing this text, you have followed the symlink. # # This is a dynamic resolv.conf file for connecting local clients directly to # all known uplink DNS servers. This file lists all configured search domains. # # Third party programs should typically not access this file directly, but only # through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a # different way, replace this symlink by a static file or a different symlink. # # See man:systemd-resolved.service(8) for details about the supported modes of # operation for /etc/resolv.conf. nameserver 192.168.64.1 search .
解决方案
方案1:启动Minikube时指定公共DNS
直接用公共DNS服务器启动Minikube,避免依赖主机DNS故障:
minikube stop minikube delete minikube start --docker-opt dns=8.8.8.8
方案2:修改Minikube内部DNS配置
进入Minikube节点,手动替换DNS配置并锁定文件防止被覆盖:
minikube ssh sudo rm /etc/resolv.conf sudo echo "nameserver 8.8.8.8" > /etc/resolv.conf sudo chattr +i /etc/resolv.conf
方案3:检查主机网络设置
- 确认Mac防火墙未阻止Minikube访问53端口(DNS服务端口)
- 将Mac系统网络设置中的DNS服务器改为公共DNS(如8.8.8.8),之后重启Minikube
方案4:切换Minikube网络驱动
若当前使用hyperkit驱动,尝试切换到docker驱动:
minikube stop minikube delete minikube start --driver=docker
内容的提问来源于stack exchange,提问作者CrazyCoder
相关产品推荐
相关产品推荐

