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 and make DNS work in the docker images.