2

On my host machine (arch linux) I have a somewhat long list of entries in the /etc/hosts file resolving to remote machines (that are not under my control). The Docker containers of a development project that I recently inherited use the domain names that should be resolved by the /etc/hosts file to communicate with different remote services.

But the running containers are not able to resolv the domain names provided by host's /etc/hosts.

That all does work under Mac OSX just fine.

I have tried adding extra_hosts to the docker-compose.yml for one entry and that worked just fine. The problem here is, that the other developers on the project have other IP resolutions in their host machine's /etc/hosts files, so using extra_hosts is not the right solution here, since I have to manually handle the docker-compose.yml outside the git repository, if I wanted to use that. Furthermore there are more than 100 domain names here, that need to be added to about a dozen docker container. Would be a very inconvenient solution.

What am I missing here?

PS: The domains are resolved within a VPN - the servers are not visible outside.


What I did try:

  • Adding IPForward=true and then IPForward=kernel to /usr/lib/systemd/network/80-container-host0.network; and then
  • disabling dnsmasq;

both described here.

  • Seems like I have to live with the workaround. I did finally end up writing all domain entries under the `extra_hosts` section in the `docker-compose.yml`. This is very inconvenient, but does the job. – Martin Penckert Aug 14 '19 at 15:27
  • You could create a script that generates the extra_hosts section – Beefster Sep 23 '20 at 20:24

0 Answers0