Docker 127.0.0.11 resolver should use host /etc/hosts file

The 127.0.0.11 docker custom dns should be able to resolve entries to the docker-hosts /etc/hosts file.

Assume the following scenario: a docker host and an external service are in the same network.
The docker container needs to reach that service, but if it resolves its ip it gets an external address, which obviously is not reachable form inside the network.
So the host gets an entry to /etc/hosts to override the ip. The container however ignores it, since its /etc/hosts file is docker managed and does not get the entries and uses 127.0.0.11, which then relays to an external nameserver like google.

->You cannot use -v /etc/hosts:/etc/hosts since /etc/hosts in the container is managed by docker (works in some scenarios)
->You cannot use the host network, because oftentimes it is not an option to break that isolation

2 Likes

Try upgrading docker.
The issue you refer to is fixed on docker version 20.10.