非竹用啥就学啥 2016-10-27
1、docker run -d -p 53:53/tcp -p 53:53/udp --cap-add=NET_ADMIN --name dns-server andyshinn/dnsmasq:2.75
本以为顺利完成,结果报错:
docker: Error response from daemon: failed to create endpoint dns-server on network bridge: Error starting userland proxy: listen tcp 0.0.0.0:53: bind: address already in use.
netstat -lnp|grep 53 dns服务默认是用的53端口被占用了。
禁用dnsmasq
删除NetworkManager配置信息
sudo vim /etc/NetworkManager/NetworkManager.conf
删除下面的内容,然后保存
dns=dnsmasq
2、docker ps
3、 docker exec -it dns-server /bin/sh
4、vi /etc/resolv.dnsmasq
nameserver 202.101.186.86
nameserver 8.8.8.8
5、vi /etc/dnsmasqhosts
172.20.2.14 www.test.cc
172.20.2.15 slave15
172.20.2.16 slave16
6、vi /etc/dnsmasq.conf
resolv-file=/etc/resolv.dnsmasq
addn-hosts=/etc/dnsmasqhosts
7、回到宿主,重启dns-server容器服务。
docker restart dns-server
8、将你的机器dns改成docker服务器的ip