Docker image DNS resolv.conf problem

Hello, everyone,

I’ve discussed this problem before here, but still did not find a permanent solution.

I’m currently running Hass.io on Ubuntu in docker. I like the convenience of it, how it self-manages containers, plugins, one-click update from the UI, it’s all very good and nice, so I don’t want to ‘just install plain hass’ or anything like that.

But there’s one huge problem that I can’t seem to solve. It’s that it’s resolv.conf file points to non existing DNS server. I don’t know where it even gets it. The result of it is that HASS can’t resolve any domain names. It can’t access OpenWeatherMap. It’s Cloud functionality is not working. And anything else that requires it to read any data from any url - does not work.

If I connect to running docker image and fix resolv.conf manually using this:

docker exec -it homeassistant /bin/bash

echo "nameserver 8.8.8.8" > /etc/resolv.conf

It works. Until I restart container, reboot server or update it.

Then it drops back it’s default contents:


nameserver 172.30.32.2
options ndots:0

How do I permanently fix this issue?

Thanks for your time and attention.

Managed to brute force it by creating a cron job that runs this command every minute or so:

docker exec -d homeassistant bash -c "echo 'nameserver 192.168.1.1' > /etc/resolv.conf"

Maybe it will be useful for someone. Replace IP with your DNS, 192.168.1.1 is my router. You can use 1.1.1.1 or 8.8.8.8 for CloudFlare’s or Google’s DNS. Also homeassistant is the name of the docker container, adjust if needed.

same issue here and ended up with the same solution. Are we the only two here?

I actually solved it completely by reinstalling HASS. Well, actually turned out reinstalling and refactoring my whole server from Ubuntu into Proxmox, but that’s not the solution :smiley: Though I’m actually happy with my new Proxmox setup now. At least now if I fail like this again it will only influence one VM, not everything.

Try removing docker images of home assisstant and hassio supervisor and running the script again. Be advised that in my case I did run apt install ... commands as well “just in case” and for some reasons (very likely unrelated to Hass) it caused apt to go and remove half of my system’s libs and failed to reinstall them. So if you decide to also reinstall dependencies from the docs page - do tha WITHOUT the -Y flag. (or -y whatever it is, causes apt to skip all prompts). And when it shows you the list of packages to remove make sure it’s not the whole system lol.

This problem is likely caused by a misconfigured docker networking. You can also try inspecting the install script to figure out what’s wrong with it exactly. But I believe re-downloading and re-creating docker containers is a required step anyway.