CoreDNS を dockerで動かす
services:
coredns:
image: coredns/coredns:1.10.1
container_name: coredns
configs:
- source: coredns
target: /Corefile
networks:
core-dns:
ipv4_address: 172.16.238.10
alpine:
image: alpine:3.18
tty: true
networks:
core-dns:
dns:
- 172.16.238.10
configs:
coredns:
file: ./Corefile
networks:
core-dns:
ipam:
driver: default
config:
- subnet: "172.16.238.0/28"
Corefile
Corefile
. {
whoami
errors
log . "{proto} {remote} Request: {name} {type} {>id}"
template IN A app.example.com {
match "^([^\.]+)\.app\.example\.com\.$"
answer "{{ index .Match 1 }}.app.example.com. IN A 192.168.10.10"
fallthrough
}
hosts {
192.168.10.11 a.example.com
192.168.10.12 b.example.com
fallthrough
}
forward . 1.1.1.1 8.8.8.8
reload
}