--add-host globally

Hey everyone,
this question has probably already been asked but I couldn’t find a solution to my problem yet.

tl;dr: Is it possible to set --add-host="" globally? For example in /etc/docker/daemon.json

Why do I want/need to do that?
We use java containers with eureka that use the hostname of the docker host + the port binding to access services dynamically. Currently we work around this issue by adding extra_hosts to the stack but it would be much easier to just set it globally on each docker host.

Steps to reproduce:
OS: Ubuntu 22.04
Docker version: 20.10.12, build e91ed57
Stack:

version: '3'
services:
  nginx:
    image: nginx:alpine
    ports:
      - '30004:80'
  busybox:
    image: busybox
    extra_hosts:
      - docker01.company.lan:host-gateway
    command: "watch -n 5 wget --spider http://docker01.company.lan:30004"

Thanks for you help :slight_smile: