for-win icon indicating copy to clipboard operation
for-win copied to clipboard

hosts file is not updated when restarting docker desktop after changing network interface.

Open ryan65 opened this issue 1 year ago • 4 comments

Description

Hi I work hybrid. at home I work wireless and at the office LAN. My docker desktop is configured to use WSL 2 based engine and I have the "Add the *.docker.internal names to the hosts..." checked. When I switch from work to home and visa versa , I use a different network interface with a different local ip. I would expect docker desktop to update the hosts file with the local ip each time I restart docker desktop, but it doesn't. My hosts file remains with the previous mapping. The only way I manage to update the hosts file is to uncheck *.docker.internal...." and then check again. Why doesnt it update the hosts file automatically each time the docker desktop restarts ? Thanks.

Reproduce

simply change the network adapter , and restart docker desktop. it doesn't update the hosts file.

Expected behavior

I would expect the hosts file to be updated with the default local ip of the current network interface , each time docker desktop is restarted.

docker version

4.29.0

docker info

4.29.0

Diagnostics ID

3EF2C50F-B991-4A34-A4A2-52D74F7F9E41/20240515055958

Additional Info

No response

ryan65 avatar May 15 '24 06:05 ryan65

I'm having the same issue on 4.30.0

dlindbergJC avatar May 23 '24 14:05 dlindbergJC

can someone please look into this . doesn't look like something too difficult to fix. thanks.

ryan65 avatar May 27 '24 04:05 ryan65

Seeing this as well with recent versions.

Only reliable fix, as OP said, is to uncheck "Add the *.docker.internal names to the host's /etc/hosts file" option, allow the engine to re-start, then check it again, and apply/restart once more. At that point, I get a prompt that the "privileged helper" is not running, and after I acknowledge that prompt, my hosts file is updated.

(Or, alternatively, manually update hosts file.)

Oddly, restarting the "Docker Desktop Service" Windows Service, which is what I thought the privileged helper was, doesn't work.

mdsharpe avatar Jun 14 '24 07:06 mdsharpe

Hi!, same here. When working in other places (other networks) host file on windows is not updated this is only triggered on docker update. The WSL 2 Option as @mdsharpe don't work for me even with privileges helper.

ljcyfran avatar Aug 27 '24 09:08 ljcyfran