Skip to content

Instantly share code, notes, and snippets.

@nerdyman
Last active October 6, 2020 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerdyman/e486b0e9a3680b79af41d2ff1ba970b3 to your computer and use it in GitHub Desktop.
Save nerdyman/e486b0e9a3680b79af41d2ff1ba970b3 to your computer and use it in GitHub Desktop.
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 ..., EAI_AGAIN (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