This article records the troubleshooting and repair of docker container dns related faults
Troubleshoot
Check URL resolution
Enter the container and use it to confirmcurl
whether the domain name can be resolved normally
docker exec -it freenom /bin/bash
Execute on the command line
curl <URL>
that curl baidu.com
appears
View DNS configuration
cat /etc/resolv.conf
Still check the nameserver of the configuration file on the command line of the container. You can change it
to confirm the available DNS server,
and then run it again to check whether it is normal.
repair
method one
docker run
Add parameters to the command to manually --dns <DNS_SERVER>
specify the DNS used by this container.
I used this
way two
The information comes from the Internet and hasbeen actually confirmed
vim /etc/docker/daemon.json
"dns" : [
"8.8.8.8",
"119.29.29.29"
]