Add extra_hosts to all containers

Viewed 28

I have a project that can be run on multiple OSes Linux/Windows/Mac. I have single docker-compose file. For Windows and MAC docker-compose starting version 18 is smart enough to add host.docker.internal automatically into containers so I can connect the containers. For Ubuntu, I have to specify every time

extra_hosts:
      - 'host.docker.internal:host-gateway'

Is there a way to always inject these additions to host files for the container whenever the container is created, so that it is similar to Windows and Mac? Am I looking at this wrongly?

I just want to avoid tedious editing of the docker-compose file because docker behaves differently on Ubuntu than on Mac and Windows.

0 Answers
Related