When docker buildx cannot resolve your container registry
I had an odd situation today when building and pushing a container image to a registry.
I have a private registry in my homelab. I have an internal DNS server that can resolve it when in my home network, and my machines in my home network all use that internal DNS server. Great, fantastic, just works.
Except for some reason, when running a docker buildx build --push operation, it was unable to resolve the internal name... because it was using the wrong DNS server. It was trying to resolve via the 8.8.8.8 DNS server. The Google DNS servers. Which I've not even configured as an upstream in my recursive DNS server on the local network.
My guess is that the Docker daemon falls back to Google DNS servers if the system DNS cannot be reached at any point. Clearly, it then never tests to see if the system DNS has become reachable again, so it gets stuck there.
The solution? Restart the docker service:
sudo systemctl restart docker
Once I did that, it resolved using the system DNS next time.