Resolve hosts computer /etc/hosts entries from within docker (works on Mac, but not on Linux)

Hi everybody,

I have setup a LAMP stack ( with dynamically configured mass virtual hosting.

Apache/Nginx are listening on my host computer on, so that I can use my Host browser to access my projects served via the docker.
For this to work, I need to add my domains (e.g.: example.loc) into my host computers etc/hosts

I added a check inside my docker that will check if a specific /etc/hosts entry exists on the docker host.
This is accomplished inside my PHP docker via:

getent hosts example.loc

However, only when running the whole setup on OSX it works.
When running the docker setup under Linux, the PHP docker is not able to resolve the docker hosts /etc/hosts

Are there any differences between the two or something that I am missing?

What is another good way from inside the docker to use the hosts /etc/hosts configuration?