1.获取coredns容器镜像
docker pull 18370952508/coredns
2.查看coredns容器镜像是否获取到本地
docker images
3.创建用于存放coredns文件的目录
mkdir /home/coredns/
cd /home/coredns/
4.创建Corefile文件用于转发forward
cat > Corefile <<EOF
.:53 {
hosts {
fallthrough
}
forward . 114.114.114.114 8.8.8.8
errors
cache
}
EOF
5.创建hosts文件,设置coredns的A记录解析
#根据实际需要修改
cat > hosts <<EOF
1.1.1.1 www.yuntle.org
2.2.2.2 web.yuntle.org
EOF
6.创建一键运行coredns的脚本,
cat > install-coredns.sh <<EOF
#!/bin/bash
docker run --name coredns -d -p 53:53/tcp -p 53:53/udp -v /home/coredns/hosts:/etc/hosts -v /home/coredns/Corefile:/Corefile 18370952508/coredns
EOF
7.shell运行容器
sh install-coredns.sh
8.查看coredns容器是否正在运行
docker ps
9.dig测试A记录解析是否正常
dig www.yuntle.org @10.0.44.252
Content type
Image
Digest
sha256:bdb36ee88…
Size
14.1 MB
Last updated
about 4 years ago
docker pull 18370952508/coredns