Add host ip to container

Is there any way to have the hosts ip address registered in the container?
Something akin to --add-host=dockerhost:$(get host ip address) when plain docker run.

I know there is a meta data service (curl rancher-metadata/self/host/agent_ip gives the address I’m after), but this requires a curl in the container with some accompanying logic to make it all work, and has to be repeated in every container that needs this ip.

What we’re after is to use services that are running on the rancher agent nodes. And I want the container to hit the host it is running on.

Preferably, there would be a label or some such we could use in the compose file that would yield the same effect as the --add-host above…

Currently, the only supported way is through metadata. We purposely put it in metadata. Since there are lots of different use cases for different information, we wanted to standardize the way to achieve it. You could create an issue in GitHub and see if there is enough user interest to put it outside of metadata, but since there is a working solution, we would point to using metadata.

Thank you Denise, I’ll think a little harder to see if I can come up with a way to use the meta data that’s transparent enough from the application perspective.