基于CoreDNS镜像

  • CoreDNS

CoreDNS 是一个 轻量级、可插件化的 DNS 服务器,可以处理正向和反向域名解析、缓存、转发等功能。它特别适合 容器化和微服务环境(如 Kubernetes 集群),通过插件机制可以灵活定制解析逻辑,同时支持日志记录和错误监控,配置简单、跨平台,适合开发和实验场景。

准备镜像和配置文件

拉取镜像

1
docker pull coredns/coredns:1.12.4

准备配置文件

Corefile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
regen.local { 
hosts {
192.168.99.203 app.regen.local
}
log
errors
}

. {
forward . 8.8.8.8 1.1.1.1 114.114.114.114
cache 30
log
errors
}

docker run

1
2
3
4
5
6
docker run -d \
--name coredns-server \
-p 53:53/udp \
-p 53:53/tcp \
-v $(pwd)/Corefile:/Corefile:ro \
coredns/coredns:1.12.4 -conf /Corefile

image-20250915172435636

测试

​ 设置好了自己网卡dns服务器之后,访问app.regen.local即可。

image-20250916090824119