How to avoid "Could not resolve host" inside Docker under heavy load?

us flag

the problem I am dealing with for months is explained very easy:

I am running PHP-FPM with docker, and whenever the server load is increasing I randomly get "Could not resolve host" errors (I guess from the curl extension).

I already changed the resolver-hosts in the docker config (i.e. google or cloudflare) and I also installed a local resolver to avoid any problems with the resolver of my hosting company.

But the main problem is not the resolver itself, it´s the fact that with a specific load-level docker is no longer able to resolve any DNS queries. I have no idea, what the reason could be. I am running a Docker Swarm and maybe the Host has only a specific amount of HTTP slots available like "open files limit" or something similar.

If anyone has an idea, please let me know.
Any help is appreciated!

in flag
I would try to switch to a resolver that supports DNS over TCP or HTTPS (and of course configure an appriate DNS server that supports it too). Regular DNS uses UDP so requests or responses can get lost easily. By using a resolver that uses TCP you could eliminate UDP as potential problem source.
michabbb avatar
us flag
thanks for your advise, but I belive the problem is not the resolver, as I already tried to explain, it's more the fact that the container is unable to get any dsn query from any resolver, maybe there is a way to let docker handle DNS queries via TCP, will check that....
michabbb avatar
us flag
BTW, this is a very interesting document about resolving udp vs tcp:

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.