Since a recent Docker update on my Windows machine, Docker Desktop started adding entries to my etc\hosts
file. I'm not sure which build introduced it, but I'm currently on Docker Desktop Community 2.1.0.1 (31799).
I want my etc\hosts
file to contain only the following entry:
127.0.0.1 localhost host.docker.internal
But every now and then, Docker Desktop adds additional entries resulting in:
127.0.0.1 localhost host.docker.internal
# Added by Docker Desktop
10.4.123.44 host.docker.internal
10.4.123.44 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
If I remove them, they eventually reappear. How do I prevent Docker from adding these entries?
Why do you not want to allow Docker to manage your hosts file? I think you may get some unwanted behaviour if you do.
That said, you can probably just make the file read only.
Right-click > Properties > Check Read Only > Apply
You'll have to update this when making changes but it will also prevent Docker from writing to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With