I need to create a local DNS server just for containers, for whitelist domain addresses.
dnsmasq.conf
port=53
domain-needed
bogus-priv
bind-interfaces
no-resolv
strict-order
server=/google.com/8.8.8.8
server=/google.com/8.8.4.4
server=/github.com/8.8.8.8
server=/github.com/8.8.4.4
server=/api.github.com/8.8.8.8
server=/api.github.com/8.8.4.4
docker-compose.yml
version: '3.8'
services:
dns-server:
restart: always
image: strm/dnsmasq
container_name: dnsmasq
volumes:
- ./dnsmasq.conf:/etc/dnsmasq.conf
ports:
- "53:53/udp"
cap_add:
- NET_ADMIN
networks:
- "custom-dns"
test-dns:
container_name: test-dns
image: nginx:latest
networks:
- "custom-dns"
dns: dns-server
networks:
custom-dns: {}
I tried set dns: "dns-server", "127.0.0.1", "172.17.0.1" but not working, in container test-dns
after command curl google.com
result
curl: (6) Could not resolve host: google.com