TL;DR: How can I get myhost.local
to resolve to my wifi interface rather than the Docker virtual network?
My desktop system's hostname is "myhost" (from /etc/hostname
etc), running Ubuntu 18.04.
The ip a
command tells me that my wifi ip address is 192.168.0.6
, and my rarely-used docker-network ip address is 172.17.0.1
.
I like to use mdns/Avahi to access my desktop, via "myhost.local", e.g. when connecting to local jupyter notebooks from other hosts on my home LAN.
For some reason, mdns is assigning two addresses to myhost.local
:
$ host myhost.local
myhost.local has address 192.168.0.6
myhost.local has address 172.17.0.1
myhost.local has IPv6 address fe80::46da:e48:c3c0:112
Jupyter notebook is running with ip=192.168.0.6
When I ping myhost.local
, or connect to http://myhost.local:8888/
it worked a few months ago, but now it tries the 172.17.0.1 address, which doesn't work for jupyter.
This seems related to the unanswered question at the Docker Community Forum: Docker network interface interferes with mDNS address.
Update: to answer a question, this is the hosts file. I think it comes from the default way that Ubuntu sets up the hosts file, so localhost
is not actually the same as myhost
, but I might have tweaked it.
$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 myhost
Bonus Update
user10489
correctly notes that other hosts will resolve myhost.local
via mdns just fine. And my underlying problem was that I wanted to know what ip address to configure in my jupyter notebook
to make it available over my wireless LAN. It's just that we don't see an easy way to use mdns on the local machine to get that answer.
The resolution to that underlying problem is this, to just figure out which ip address I have on a given interface (here illustrated with Ubuntu's awkwardly-named first wireless network name):
dev=wlp3s0
ip=$(ip -br -o a show $dev | (read interface status ip ip6; echo ${ip%/*}))
jupyter notebook --no-browser --ip=$ip