Skip to content

Instantly share code, notes, and snippets.

@nerdyman nerdyman/fix-docker-dns.md
Last active Apr 22, 2020

Embed
What would you like to do?
Fix docker DNS not working on Linux hosts

Docker DNS issues on systemd distros

(Hopefully) fix Docker DNS issues with systemd distros, e.g. ping: bad address 'google.com', Temporary failure resolving ... (tested on Arch).

Checklist

  1. Host DNS is correct (/etc/resolv.conf) and does not contain any invalid nameservers
  2. Ensure DNS resolves correctly (dig google.com @ipaddress.from.resolvconf.here)
  3. Ensure Docker container has same config as host docker run -it <your-image> cat /etc/resolv.conf

Solution

  1. Allow docker network interface through firewall firewall-cmd --permanent --zone=trusted --change-interface=docker0
  2. Reload firewall firewall-cmd --reload
  3. Restart firewall service systemctl restart firewalld
  4. Restart network (I use NetworkManager) systemctl restart NetworkManager
  5. Kill all the Docker things docker system prune --all --force
  6. Restart Docker systemctl restart docker
  7. Try ping on image docker run -it <your-image> cat /etc/resolv.conf

Example test: docker run busybox ping -c 3 google.com

Nuclear Solution

If all else fails try stopping firewalld altogether systemctl stop firewalld

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.