Docker-compose.yml how to implement value redundancy

example docker compose file

version: '3.0'
    image: api1image
    image: api2image

so in the example above, how do I implement extra_host without having to change everything 1 by 1?
is there a way I can declare extra_host as a environment variable even if it is an array? so I can reuse it again and again.

my use-case is that we have a background api engine that we don’t want to put on docker, and we want someapi1 and someapi2 to be able to make a curl request to and

as for why we don’t want to put in a container, Its what our dev team lead wants, I have no power to object over it.

also, im using windows container by the way and extra_hosts doesn’t seem to work

have a look at

Yaml allows you to define blocks which you later can reuse. So define your extrahost-list once and then use it for all your services.
Is this what you want? Does it help you?