Sudo: unable to resolve host ubuntu: Name or service not known

Hello,

I installed PiHole in Docker on Ubuntu 20.04.1 on RPi4. I had to struggle with the DNS port conflict a little, and I used this post to fix it: https://discourse.pi-hole.net/t/setup-on-pi-in-docker-bind-error/19137/5

Now everything is fine except that whenever I run sudo commands in the Ubuntu terminal I get: sudo: unable to resolve host ubuntu: Name or service not known

Any idea what did I do wrong? Thank you!

You haven't done anything wrong.

Every time you run sudo there is a lookup to the sudoers configuration files. One thing you can do with sudoers is set per machine/host rules. Part of that process means that every sudo call looks up the hostname to see if you've been granted priv's on that host. DNS doesn't know who ubuntu is so it logs a warning. Doesn't affect anything, just clutters up logs.

Easy solution would be to tell the host who ubuntu is. Either a custom DNS entry or a change to /etc/hosts, but changing /etc/hosts will disappear when you start a new container.

1 Like