Handle docker container error "cURL error 6: Could not resolve host"

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.comappears

View DNS configuration


cat /etc/resolv.confStill 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 runAdd 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"
]

Guess you like

Origin blog.csdn.net/sean908/article/details/124958708