docker-compose 搭建DNS
docker-compose 搭建DNSDNS搭建
1、配置docker-compose文件
version: '3.7'
services:
dns-server:
container_name: dns-server
image: 'jpillora/dnsmasq'
restart: always
environment:
- TZ=Asia/Shanghai
- HTTP_USER=foo
- HTTP_PASS=bar
ports:
- "53:53/udp"
- "5380:8080"
volumes:
- "./dns/dnsmasq.conf:/etc/dmZsmasq.conf"
2、启动docker-compose 并且进入dns管理平台(http://localhost:5380/)
docker-compose up -d
3、Linux 配置dns私服,并校验是否成功
- 打开dns配置文件
sudo vim /etc/resolv.conf
- 追加命令
nameserver 127.0.0.1
- 验证
ping yujuan
4、注意事项
- docker-compose 隐射端口时,一定要指定udp类型端口( - "53:53/udp"),否则不成功