Hassio Docker DNS resolve not working

I’ve got lots of DNS trouble after installing HASSIO on an existing linux server.

*I downloaded and installed Hassio in docker by executing

curl -sL https://raw.githubusercontent.com/home-assistant/hassio-build/master/install/hassio_install | bash -s

Problem
DNS does not resolve, some proof:

$  docker exec -it homeassistant ping google.com
ping: bad address 'google.com' [NOK]

$docker exec -it homeassistant ping 172.217.17.78
PING 172.217.17.78 (172.217.17.78): 56 data bytes 
64 bytes from 172.217.17.78: seq=0 ttl=56 time=8.312 ms [OK, but no DNS used]

$ docker logs homeassistant | grep error
.....
2018-09-21 14:33:31 ERROR (MainThread) [homeassistant.components.cloud] Error fetching Cognito 
keyset: Cannot connect to host cognito-idp.us-east-1.amazonaws.com:443 ssl:None [Try again]
....

$ docker logs hassioaddons/node-red-amd64
....
curl: (6) Could not resolve host: api.pwnedpasswords.com
ERROR: Something went wrong contacting the HIBP API  [NOK]
WARNING: Could not check password, assuming it is safe.
FATAL: The configured certfile is not found

Attemts to fix

1: set dns option docker wide

$ echo {"dns": ["8.8.8.8"]} > /etc/docker/daemon.json   -> set standard DNS service to google
$ service docker restart
$ docker rm -f $(docker ps -aq)   -> kill all docker containers
$ systemctl restart hassio-supervisor.service  -> restart hassio and homeassistant docker container

2: get dns settings from /etc/resolv.conf

$ docker exec -it homeassistant /bin/sh
$ cat /etc/resolv.conf
nameserver 172.30.32.2   -> internal docker DNS?
options ndots:0
Set the dns server manually in the container:
$ echo nameserver 8.8.8.8 > /etc/resolv.conf
$ ping google.com
PING google.com (172.217.17.78): 56 data bytes
64 bytes from 172.217.17.78: seq=0 ttl=56 time=8.567 ms  [OK! nice!]
But fix 2 seems to be gone after reboot of container from the host:
$exit -> back to host pc
$docker stop homeassistant
$ systemctl restart hassio-supervisor
$docker exec -it homeassistant /bin/sh
$cat /etc/resolv.conf
nameserver 172.30.32.2  -> [NOK, back to original]
options ndots:0
$ping google.com
ping: bad address 'google.com' [NOK, DNS does not resolve after restart homeassistant container]

I’ve already spent LOTS of hours on this, hopefully you are able to help me out :slight_smile: and make DNS work in the docker images.

So I hope this helps but it took forever for me to get this to work on my nuc. In your attempts to fix 1 you have
$ echo {“dns”: [“8.8.8.8”]} > /etc/docker/daemon.json

I had to add in my ip of my nuc before the google dns to work. So same as you have it but [“xxx.xxx.xxx.xxx”, “8.8.8.8”]

When I ran your command hassio would become unreachable. I would delete and start over. With my command duckdns was finally able to install because everything resolved. No more errors

Thanks a lot for your message BerryClam, unfortunately DNS still does not work with xxx being the IP both of the router and the local network card (tried both).
192.168.2.1 [router] & 192.168.5.111 [pc] → =bridged

Something strange:

  • DNS ping google inside homeassistant docker container fails:
$ docker exec -it homeassistant /bin/bash
$ ping google.com [FAILS]
  • DNS also fails for homeassistant discovery on boot
$docker logs homeassistant
....
2018-09-23 07:37:01 ERROR (MainThread) [homeassistant.components.sensor.yr] Retrying in 19 minutes: Cannot connect to host aa015h6buqvih86i1.api.met.no:443 ssl:None [Try again]
...

BUT installing addons from the addon broser in hassio ([local ip]:8123) finished OK!, e.g. node-red. I think that this should not be possible (unless static IP’s are used).

Starting node-red itself then fails; checking the node-red logs shows that DNS requests to check the entered password strenghts fail. So a new node-red container again also has no DNS.

SOLVED:
apt-get install installs old version of docker.
removed docker; performed apt purge, apt autosave;
installed docker using:

curl -sSL https://get.docker.com | sh

as part of:

1 Like