centos 8 docker-ce 安装 dns问题处理


https://www.techrepublic.com/article/a-better-way-to-install-docker-on-centos-8/
https://linuxconfig.org/how-to-install-docker-in-rhel-8
https://yq.aliyun.com/articles/110806

centos8目前直接安装会提示containerd.io版本不支持的问题,此时可以通过--nobest选项安装,不过这样安装,每次更新时都会有警告提示。所以最好还是先装好高版本的containerd.io再装docker-ce
docker的rpm官方包在https://download.docker.com/linux/centos/7/x86_64/stable/Packages/可以下载,
也可使用镜像地址:http://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/

dnf config-manager --add-repo=http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
dnf install http://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm
dnf install docker-ce

由于centos 8 将iptables替换为nftables,docker存在兼容性问题,会出现dns功能无法解析的bug。你可以busybox容器校验

docker run busybox nslookup baidu.com

参考:https://forums.centos.org/viewtopic.php?f=54&t=74270

有三种方式可以处理,任选其一即可:

1.启用masquerade(建议)

firewall-cmd --zone=public  --add-masquerade --permanent
firewall-cmd --reload

参考:https://linuxconfig.org/how-to-install-docker-in-rhel-8 中的评论

2.让firewalld使用iptables

#修改/etc/firewalld/firewalld.conf
#FirewallBackend=nftables
FirewallBackend=iptables

sudo systemctl restart firewalld.service

参考:https://github.com/docker/for-linux/issues/957#issuecomment-627166787

3.添加docker0网口为信任(不建议,docker-compose的dns问题未修复,会对外开放所有发布的容器端口)

firewall-cmd --permanent --zone=trusted --add-interface=docker0

参考:https://forums.centos.org/viewtopic.php?f=54&t=74270

对DNS问题的测试方法,请见:https://github.com/docker/for-linux/issues/957#issuecomment-658649036


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM