IT seems there is something wrong with your DNS setting. Maybe you already fixed it but Docker was not restarted since then or the containers were not recreated sicne then.
Have you configured multiple DNS servers either in /etc/docker/daemon.json or iwhen you started the containers, or anywhere on the host?
I can imagine that the host either has a different DNS setting or it handles multiple DNS servers differently. If you for example also set 127.0.0.1 somewhere that one of the DNS servers return, that could cause the issue.