Adding extra hosts during runtime in docker container

I have a multi-container application in which one of the containers resolves a hostname (let’s say “myexample.com”) and retrieves its IP via mDNS during runtime.

I would like to register this new host within the multi-container environment.

My first thought was to symlink a named volume to each /etc/hosts in the containers, and then write to it. However, during runtime in BalenaOS, that operation on /etc/hosts returns “/etc/hosts’: Device or resource busy’”, meaning I can’t even create the symlink.

Is there an easy way to set additional hosts from inside a container that is visible to the other containers?