Docker issues are frequently logged for DNS resolution in containers because it doens't inhert or get values for DNS from NetworkManager which leverages a built in dnsmasq to inteligently manage DNS.
sudo bash -c "echo listen-address=$(ip -4 addr show dev docker0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') > /etc/NetworkManager/dnsmasq.d/docker-bridge"
sudo systemctl reload NetworkManager
sudo bash -c 'echo -e "{\n\t\"dns\": [\"$(ip -4 addr show dev docker0 | grep -oP "(?<=inet\s)\d+(\.\d+){3}")\"]\n}" > /etc/docker/daemon.json'
sudo systemctl restart docker
Note:
- makes dnsmasq plugin for network manager listen on the host's docker bridge interface
- adds (clobbers!) the daemon.json - take care, could overwrite other customisations you already have there...
The bash one liner below generates the dns attributes needed for docker
nm_dns=$(for d in $(nmcli device show | grep -E "^IP4.DNS" | grep -oP '(\d{1,3}\.){3}\d{1,3}'); do echo -n " --dns $d"; done)
sudo -E docker run -it --rm -e http_proxy -e https_proxy -e no_proxy $nm_dns ubuntu
Ain't pretty, but works... (until they change the nmcli output format or something)
Related issues with docker DNS:
The permanent fix works for me, but not at boot:
If I restart NetworkManager after the boot, it works. Did you have this issue as well ?